Esempio n. 1
0
    def onSave(self):
        index = self.ui.adj_layer.currentIndex()
        if index < 0: return

        adj_layer_id, ok = self.ui.adj_layer.itemData(index).toInt()
        adj_layer = SQLClientHelper.GetAdjLayerById(adj_layer_id)
        if adj_layer.id <= 0:
            UiHelper.MessageBox(u'sorry,出了点问题,请联系技术人员(错误码:P1)!')
            return

        # 得到邻近层关联的煤层
        coal_id = adj_layer.coal_id
        coal = None
        if coal_id <= 0:
            coal = Coal()
        else:
            coal = SQLClientHelper.GetCoalById(coal_id)
        # 读取界面数据到煤层
        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()

        # 保存煤层到数据库(如果煤层为空)
        if coal_id <= 0:
            coal_id = SQLClientHelper.AddCoal(coal)
        if coal_id <= 0:
            UiHelper.MessageBox(u'sorry,出了点问题,请联系技术人员(错误码:P2)!')
            return
        else:
            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())

        # 保存煤层到数据库
        if not SQLClientHelper.UpdateCoal(coal):
            UiHelper.MessageBox(u'更新邻近层数据失败!')
            return

        # 保存邻近层到数据库
        if not SQLClientHelper.UpdateAdjLayer(adj_layer):
            UiHelper.MessageBox(u'更新邻近层数据失败!')
        else:
            UiHelper.MessageBox(u'更新邻近层数据成功!')
Esempio n. 2
0
    def onAdjLayerChanged(self, index):
        # 根据id查找当前邻近层
        if index < 0: return
        adj_layer_id, ok = self.ui.adj_layer.itemData(index).toInt()
        if adj_layer_id <= 0: return
        adj_layer = SQLClientHelper.GetAdjLayerById(adj_layer_id)

        # 查找邻近层关联的煤层
        coal_id = adj_layer.coal_id
        if coal_id <= 0: return
        coal = SQLClientHelper.GetCoalById(coal_id)

        # 更新煤层数据到界面上
        self.ui.thick.setText(u'%.1f' % coal.thick)
        self.ui.gas_eta.setText(u'%.1f' % coal.gas_eta)
        self.ui.gas_w0.setText(u'%.1f' % coal.gas_w0)
        self.ui.gas_wc2.setText(u'%.1f' % coal.gas_wc2)

        # 更新邻近层数据到界面上
        self.ui.h.setText(u'%.1f' % adj_layer.h)
        self.ui.hp.setText(u'%.1f' % adj_layer.hp)
        self.ui.in_cz.setChecked(adj_layer.in_cz != 0)