コード例 #1
0
ファイル: MineDesignDlg.py プロジェクト: liulaojian/cbm
    def onDelCoal(self):
        # 从数据库删除煤层(sql内部的级联delete机制可以保证关联的work_surf、drilling_surf同时也被删除)
        index = self.ui.coal.currentIndex()
        if index < 0: return

        if not UiHelper.MessageBox(u'您确定要删除该煤层?', question=True):
            return

        coal_id, ok = self.ui.coal.itemData(index).toInt()
        if SQLClientHelper.DeleteCoal(coal_id):
            # 从采区列表中删除
            self.ui.coal.removeItem(index)
            self.ui.coal.setCurrentIndex(0)
            UiHelper.MessageBox(u'删除煤层成功!')
コード例 #2
0
    def onAddAdjLayer(self):
        # 弹出名称对话框,获取名称
        name = unicode(UiHelper.GetNameFromDlg(u"新增邻近层"))
        if name == u'null':
            UiHelper.MessageBox(u"请输入有效的名称!")
            return

        # 新建邻近层,并提交到数据库
        adj_layer = AdjLayer()
        adj_layer.name = name.encode('utf-8')
        adj_layer.work_surf_id = self.work_surf_id
        # 新建煤层(要邻近层关联),提交到数据库获得煤层id
        coal = Coal()
        # 读取界面数据到煤层(这里是为了防止出现None导致计算失败!!)
        # 如果采用其它语言实现,可以不需要这段代码
        coal.thick, ok = self.ui.thick.text().toDouble()
        coal.gas_eta, ok = self.ui.gas_eta.text().toDouble()
        coal.gas_w0, ok = self.ui.gas_w0.text().toDouble()
        coal.gas_wc2, ok = self.ui.gas_wc2.text().toDouble()
        print '---------------->:', coal.gas_w0, '----:', coal.gas_wc2
        coal_id = SQLClientHelper.AddCoal(coal)
        if coal_id <= 0:
            UiHelper.MessageBox(u"新增邻近层失败")
            return

        # 新建邻近层与新建煤层关联在一起,并提交到数据库
        adj_layer.coal_id = coal_id
        adj_layer.hp, ok = self.ui.hp.text().toDouble()
        adj_layer.h, ok = self.ui.h.text().toDouble()
        adj_layer.in_cz = int(self.ui.in_cz.isChecked())
        adj_layer_id = SQLClientHelper.AddAdjLayer(adj_layer)
        if adj_layer_id <= 0:
            # 删除之前新增的煤层
            SQLClientHelper.DeleteCoal(coal_id)
            UiHelper.MessageBox(u"新增邻近层失败")
        else:
            # 添加到邻近层下拉列表
            index = UiHelper.AddItemToCombobox(self.ui.adj_layer, name,
                                               adj_layer_id)
            # 切换到新增item
            self.ui.adj_layer.setCurrentIndex(index)
            UiHelper.MessageBox(u'新增邻近层成功!')