Ejemplo n.º 1
0
        /// <summary>
        /// 根据用户号更新开票相关基础信息
        /// </summary>
        /// <param name="MODELWaterUser"></param>
        /// <returns></returns>
        public bool UpdateUserByWaterUserNO(MODELWaterUser MODELWaterUser)
        {
            StringBuilder str = new StringBuilder();

            str.Append("UPDATE waterUser SET waterUserName=@waterUserName,waterPhone=@waterPhone," +
                       "waterUserAddress=@waterUserAddress,FPTaxNO=@FPTaxNO,FPBankNameAndAccountNO=@FPBankNameAndAccountNO ");
            str.Append("WHERE waterUserNO=@waterUserNO");
            SqlParameter[] para =
            {
                new SqlParameter("@waterUserName",          SqlDbType.VarChar,  70),
                new SqlParameter("@waterPhone",             SqlDbType.VarChar,  50),
                new SqlParameter("@waterUserAddress",       SqlDbType.VarChar, 100),
                new SqlParameter("@FPTaxNO",                SqlDbType.VarChar,  50),
                new SqlParameter("@FPBankNameAndAccountNO", SqlDbType.VarChar, 100),
                new SqlParameter("@waterUserNO",            SqlDbType.VarChar, 30)
            };
            para[0].Value = MODELWaterUser.waterUserName;
            para[1].Value = MODELWaterUser.waterPhone;
            para[2].Value = MODELWaterUser.waterUserAddress;
            para[3].Value = MODELWaterUser.FPTaxNO;
            para[4].Value = MODELWaterUser.FPBankNameAndAccountNO;
            para[5].Value = MODELWaterUser.waterUserNO;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void btSetUp_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text.Trim() == "")
                {
                    mes.Show("用户名不能为空!");
                    txtName.Focus();
                    return;
                }
                MODELWaterUser MODELWaterUser = new MODELWaterUser();
                MODELWaterUser.waterUserNO            = txtWaterUserNO.Text;
                MODELWaterUser.waterUserName          = txtName.Text;
                MODELWaterUser.waterPhone             = txtTel.Text;
                MODELWaterUser.waterUserAddress       = txtAddress.Text;
                MODELWaterUser.FPTaxNO                = txtTaxNO.Text;
                MODELWaterUser.FPBankNameAndAccountNO = txtBankNameAndAccountNO.Text;

                if (BLLwaterUser.UpdateUserByWaterUserNO(MODELWaterUser))
                {
                    mes.Show("设置成功!");
                    return;
                }
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
                return;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改新的用户名
        /// </summary>
        /// <param name="MODELWaterUser"></param>
        /// <returns></returns>
        public bool UpdateUserName(MODELWaterUser MODELWaterUser)
        {
            StringBuilder str = new StringBuilder();

            str.Append("UPDATE waterUser SET waterUserName=@waterUserName ");
            str.Append("WHERE waterUserId=@waterUserId");
            SqlParameter[] para =
            {
                new SqlParameter("@waterUserName", SqlDbType.VarChar, 70),
                new SqlParameter("@waterUserId",   SqlDbType.VarChar, 30)
            };
            para[0].Value = MODELWaterUser.waterUserName;
            para[1].Value = MODELWaterUser.waterUserId;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btChange_Click(object sender, EventArgs e)
        {
            try
            {
                if (strRecordID.Trim() == "")
                {
                    mes.Show("抄表记录ID为空,请重新查询抄表记录后再修改用户名!");
                    return;
                }
                if (txtWaterUserNameNew.Text.Trim() == "")
                {
                    mes.Show("请输入新用户名!");
                    txtWaterUserNameNew.Focus();
                    return;
                }
                if (mes.ShowQ("确定要变更'" + strWaterUserName + "'的用户名吗?") != DialogResult.OK)
                {
                    return;
                }
                MODELreadMeterRecord MODELreadMeterRecord = new MODELreadMeterRecord();

                MODELreadMeterRecord.waterUserName = txtWaterUserNameNew.Text;

                MODELreadMeterRecord.readMeterRecordId = strRecordID;
                if (BLLreadMeterRecord.UpdateHandSetWaterUserName(MODELreadMeterRecord))
                {
                    try
                    {
                        MODELWaterUser MODELWaterUser = new MODELWaterUser();
                        MODELWaterUser.waterUserId   = strWaterUserID;
                        MODELWaterUser.waterUserName = txtWaterUserNameNew.Text;
                        if (BLLwaterUser.UpdateUserName(MODELWaterUser))
                        {
                            frmWaterMeterRead.dgWaterList.CurrentRow.Cells["waterUserName"].Value = txtWaterUserNameNew.Text;
                            MODELOPERATORLOG MODELOPERATORLOG = new MODELOPERATORLOG();
                            MODELOPERATORLOG.METERREADINGID = strMeterReadingID;
                            MODELOPERATORLOG.LOGCONTENT     = "变更用户名:" + MODELWaterUser.waterUserId + "-" + txtWaterUserName.Text + "→" + MODELWaterUser.waterUserName;
                            MODELOPERATORLOG.LOGTYPE        = "1"; //1代表用户 2代表水表
                            MODELOPERATORLOG.OPERATORID     = strLogID;
                            MODELOPERATORLOG.OPERATORNAME   = strUserName;
                            BLLOPERATORLOG.Insert(MODELOPERATORLOG);
                            mes.Show("户名变更成功!");
                            btChange.Enabled = false;
                        }
                    }
                    catch (Exception)
                    {
                        mes.Show("户名基础信息变更失败,请重试!");
                        return;
                    }
                }
                else
                {
                    mes.Show("抄表记录户名变更失败,请重试!");
                    return;
                }
            }
            catch (Exception ex)
            {
                mes.Show("抄表记录户名变更失败,原因:" + ex.ToString());
                log.Write(ex.ToString(), MsgType.Error);
                return;
            }
        }
Ejemplo n.º 5
0
        public bool InsertwaterUser(MODELWaterUser MODELWaterUser)
        {
            StringBuilder str = new StringBuilder();

            str.Append("INSERT INTO waterUser(waterUserId,waterUserNO,waterUserName,waterUserNameCode,waterUserCerficateType,waterUserCerficateNO," +
                       "waterUserTelphoneNO,waterPhone,waterUserAddress,waterUserPeopleCount,areaNO,pianNO,duanNO,communityID,buildingNO,unitNO,meterReaderID," +
                       "meterReaderName,chargerID,chargerName," +
                       "meterReadingID,meterReadingPageNo,waterUserTypeId,waterUserCreateDate,operatorName,waterUserHouseType,agentsign,bankId," +
                       "BankAcountNumber,createType,memo,ordernumber,chargeType) ");
            str.Append("VALUES(@waterUserId,@waterUserNO,@waterUserName,@waterUserNameCode,@waterUserCerficateType,@waterUserCerficateNO,@waterUserTelphoneNO," +
                       "@waterPhone,@waterUserAddress,@waterUserPeopleCount,@areaNO,@pianNO,@duanNO,@communityID,@buildingNO,@unitNO,@meterReaderID," +
                       "@meterReaderName,@chargerID,@chargerName," +
                       "@meterReadingID,@meterReadingPageNo,@waterUserTypeId,@waterUserCreateDate,@operatorName,@waterUserHouseType,@agentsign,@bankId," +
                       "@BankAcountNumber,@createType,@memo,@ordernumber,@chargeType)");
            SqlParameter[] para =
            {
                new SqlParameter("@waterUserId",            SqlDbType.VarChar,    30),
                new SqlParameter("@waterUserNO",            SqlDbType.VarChar,    30),
                new SqlParameter("@waterUserName",          SqlDbType.VarChar,    50),
                new SqlParameter("@waterUserNameCode",      SqlDbType.VarChar,    50),
                new SqlParameter("@waterUserCerficateType", SqlDbType.VarChar,    50),
                new SqlParameter("@waterUserCerficateNO",   SqlDbType.VarChar,    50),
                new SqlParameter("@waterUserTelphoneNO",    SqlDbType.VarChar,    50),
                new SqlParameter("@waterPhone",             SqlDbType.VarChar,    50),
                new SqlParameter("@waterUserAddress",       SqlDbType.VarChar,   100),
                new SqlParameter("@waterUserPeopleCount",   SqlDbType.Int),
                new SqlParameter("@areaNO",                 SqlDbType.VarChar,    50),
                new SqlParameter("@pianNO",                 SqlDbType.VarChar,    50),
                new SqlParameter("@duanNO",                 SqlDbType.VarChar,    50),
                new SqlParameter("@communityID",            SqlDbType.VarChar,    50),
                new SqlParameter("@buildingNO",             SqlDbType.VarChar,    50),
                new SqlParameter("@unitNO",                 SqlDbType.VarChar,    50),
                new SqlParameter("@meterReaderID",          SqlDbType.VarChar,    50),
                new SqlParameter("@meterReaderName",        SqlDbType.VarChar,    50),
                new SqlParameter("@chargerID",              SqlDbType.VarChar,    50),
                new SqlParameter("@chargerName",            SqlDbType.VarChar,    50),
                new SqlParameter("@meterReadingID",         SqlDbType.VarChar,    30),
                new SqlParameter("@meterReadingPageNo",     SqlDbType.VarChar,    30),
                new SqlParameter("@waterUserTypeId",        SqlDbType.VarChar,    30),
                new SqlParameter("@waterUserCreateDate",    SqlDbType.DateTime),
                new SqlParameter("@operatorName",           SqlDbType.VarChar,    30),
                new SqlParameter("@waterUserHouseType",     SqlDbType.VarChar,    10),
                new SqlParameter("@agentsign",              SqlDbType.VarChar,    10),
                new SqlParameter("@bankId",                 SqlDbType.VarChar,    30),
                new SqlParameter("@BankAcountNumber",       SqlDbType.VarChar,    50),
                new SqlParameter("@createType",             SqlDbType.VarChar,    50),
                new SqlParameter("@MEMO",                   SqlDbType.VarChar,   200),
                new SqlParameter("@ordernumber",            SqlDbType.Int),
                new SqlParameter("@chargeType",             SqlDbType.VarChar, 10)
            };
            para[0].Value  = MODELWaterUser.waterUserId;
            para[1].Value  = MODELWaterUser.waterUserNO;
            para[2].Value  = MODELWaterUser.waterUserName;
            para[3].Value  = MODELWaterUser.waterUserNameCode;
            para[4].Value  = MODELWaterUser.waterUserCerficateType;
            para[5].Value  = MODELWaterUser.waterUserCerficateNO;
            para[6].Value  = MODELWaterUser.waterUserTelphoneNO;
            para[7].Value  = MODELWaterUser.waterPhone;
            para[8].Value  = MODELWaterUser.waterUserAddress;
            para[9].Value  = MODELWaterUser.waterUserPeopleCount;
            para[10].Value = MODELWaterUser.areaNO;
            para[11].Value = MODELWaterUser.pianNO;
            para[12].Value = MODELWaterUser.duanNO;
            para[13].Value = MODELWaterUser.communityID;
            para[14].Value = MODELWaterUser.buildingNO;
            para[15].Value = MODELWaterUser.unitNO;
            para[16].Value = MODELWaterUser.meterReaderID;
            para[17].Value = MODELWaterUser.meterReaderName;
            para[18].Value = MODELWaterUser.chargerID;
            para[19].Value = MODELWaterUser.chargerName;
            para[20].Value = MODELWaterUser.meterReadingID;
            para[21].Value = MODELWaterUser.meterReadingPageNo;
            para[22].Value = MODELWaterUser.waterUserTypeId;
            para[23].Value = MODELWaterUser.waterUserCreateDate;
            para[24].Value = MODELWaterUser.operatorName;
            para[25].Value = MODELWaterUser.waterUserHouseType;
            para[26].Value = MODELWaterUser.agentsign;
            para[27].Value = MODELWaterUser.bankId;
            para[28].Value = MODELWaterUser.BankAcountNumber;
            para[29].Value = MODELWaterUser.createType;
            para[30].Value = MODELWaterUser.MEMO;
            para[31].Value = MODELWaterUser.ordernumber;
            para[32].Value = MODELWaterUser.chargeType;

            if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void toolSaveUser_Click(object sender, EventArgs e)
        {
            #region 用户验证
            int intStartNO = 0, intCount = 1, intOrderNumberStart = 1;
            if (txtWaterUserNOStart.Text.Trim() == "")
            {
                mes.Show("请输入用户编号!");
                txtWaterUserNOStart.Focus();
                return;
            }
            else
            {
                string strWaterUserNOStart = txtWaterUserNOStart.Text;
                if (strWaterUserNOStart.Length == 6)
                {
                    if (strWaterUserNOStart.Substring(0, 1) != "U")
                    {
                        mes.Show("用户号由'U'+5位数字组成,请重新填写!");
                        txtWaterUserNOStart.SelectAll();
                        return;
                    }
                    else
                    {
                        if (!Information.IsNumeric(strWaterUserNOStart.Substring(1, 5)))
                        {
                            mes.Show("用户号由'U'+5位数字组成,请重新填写!");
                            txtWaterUserNOStart.SelectAll();
                            return;
                        }
                        else
                        {
                            intStartNO = Convert.ToInt32(strWaterUserNOStart.Substring(1, 5));
                        }
                    }
                }
                else
                {
                    mes.Show("用户号由'U'+5位数字组成,请重新填写!");
                    txtWaterUserNOStart.SelectAll();
                    return;
                }
            }
            if (!Information.IsNumeric(txtCount.Text))
            {
                mes.Show("请输入正确的数量!");
                txtCount.SelectAll();
                return;
            }
            else
            {
                if (Convert.ToInt16(txtCount.Text) < 1)
                {
                    mes.Show("请输入大于0的整数!");
                    txtCount.SelectAll();
                    return;
                }
                else
                {
                    intCount = Convert.ToInt16(txtCount.Text);
                }
            }

            //if (txtWaterUserName.Text.Trim() == "")
            //{
            //    mes.Show("请输入用户名称!");
            //    txtWaterUserName.Focus();
            //    return;
            //}
            if (txtWaterUserCount.Text.Trim() == "")
            {
                mes.Show("请输入人口数量!");
                txtWaterUserCount.Focus();
                return;
            }

            string strWaterUserIsExist = "SELECT * FROM WATERUSER WHERE WATERUSERID BETWEEN 'U" + intStartNO.ToString().PadLeft(5, '0')
                                         + "' AND 'U" + (intStartNO + intCount).ToString().PadLeft(5, '0') + "'";
            DataTable dtWaterUserQuery = BLLwaterUser.QuerySQL(strWaterUserIsExist);
            if (dtWaterUserQuery.Rows.Count > 0)
            {
                string strWaterUserIDS = "";
                for (int i = 0; i < dtWaterUserQuery.Rows.Count; i++)
                {
                    object objWaterUserID = dtWaterUserQuery.Rows[i]["WATERUSERID"];
                    if (objWaterUserID != null && objWaterUserID != DBNull.Value)
                    {
                        if (strWaterUserIDS == "")
                        {
                            strWaterUserIDS = objWaterUserID.ToString();
                        }
                        else
                        {
                            strWaterUserIDS += ";" + objWaterUserID.ToString();
                        }
                    }
                }
                mes.Show("存在已使用的用户号'" + strWaterUserIDS + "'");
                return;
            }

            if (cmbAreaNO.SelectedValue == null || cmbAreaNO.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择区号!");
                cmbAreaNO.Focus();
                return;
            }
            if (cmbPianNO.SelectedValue == null || cmbPianNO.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择片号!");
                cmbPianNO.Focus();
                return;
            }
            if (cmbDuanNO.SelectedValue == null || cmbDuanNO.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择段号!");
                cmbDuanNO.Focus();
                return;
            }
            if (cmbCommunity.SelectedValue == null || cmbCommunity.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择小区!");
                cmbCommunity.Focus();
                return;
            }
            if (cmbMeterReader.SelectedValue == null || cmbMeterReader.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择抄表员!");
                cmbMeterReader.Focus();
                return;
            }
            if (cmbCharger.SelectedValue == null || cmbCharger.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择收费员!");
                cmbCharger.Focus();
                return;
            }
            if (cmbCreateType.SelectedIndex < 0)
            {
                mes.Show("请选择建档类型!");
                cmbCreateType.Focus();
                return;
            }
            if (!Information.IsNumeric(txtOrderNumber.Text))
            {
                mes.Show("请输入正确的顺序号!");
                txtOrderNumber.Focus();
                return;
            }
            else
            {
                intOrderNumberStart = Convert.ToInt32(txtOrderNumber.Text);
            }

            if (cmbCerficateType.Text != "")
            {
                if (txtCerficateNO.Text.Trim() == "")
                {
                    mes.Show("请输入证件编号!");
                    cmbUserType.Focus();
                    return;
                }
            }
            if (cmbWaterUserChargeType.Text == "")
            {
                mes.Show("请选择交费方式!");
                cmbWaterUserChargeType.Focus();
                return;
            }
            if (cmbAgentSign.Text == "")
            {
                mes.Show("请设置银行是否托收!");
                cmbAgentSign.Focus();
                return;
            }
            else
            {
                if (cmbAgentSign.Text == "托收")
                {
                    if (cmbAgentBank.SelectedValue == null || cmbAgentBank.SelectedValue == DBNull.Value)
                    {
                        mes.Show("请选择托收银行!");
                        cmbAgentBank.Focus();
                        return;
                    }
                    if (txtWaterUserBankNO.Text.Trim() == "")
                    {
                        mes.Show("请输入银行卡号!");
                        txtWaterUserBankNO.Focus();
                        return;
                    }
                }
            }
            #endregion

            #region 水表验证

            if (cmbWaterMeterSize.SelectedValue == null || cmbWaterMeterSize.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择水表口径!");
                cmbWaterMeterSize.Focus();
                return;
            }
            if (cmbWaterType.SelectedValue == null || cmbWaterType.SelectedValue == DBNull.Value)
            {
                mes.Show("请选择用水类别!");
                cmbWaterType.Focus();
                return;
            }
            if (cmbWaterMeterState.Text == "")
            {
                mes.Show("请选择水表状态!");
                cmbWaterMeterState.Focus();
                return;
            }
            if (!Information.IsNumeric(txtWaterMeterStartNum.Text))
            {
                mes.Show("初始读数只能为整数!");
                txtWaterMeterStartNum.Focus();
                return;
            }
            if (!Information.IsNumeric(txtWaterMeterMagnification.Text))
            {
                mes.Show("倍率只能为整数!");
                txtWaterMeterMagnification.Focus();
                return;
            }
            if (!Information.IsNumeric(txtWaterMeterMaxRange.Text))
            {
                mes.Show("最大量程只能为整数!");
                txtWaterMeterMaxRange.Focus();
                return;
            }
            if (!Information.IsNumeric(txtProofreadingPeriod.Text))
            {
                mes.Show("鉴定周期只能为整数!");
                txtProofreadingPeriod.Focus();
                return;
            }
            if (!Information.IsNumeric(txtWaterMeterFixedValue.Text))
            {
                mes.Show("定量用水只能为整数!");
                txtWaterMeterFixedValue.Focus();
                return;
            }
            if (cmbIsSummary.Text == "")
            {
                mes.Show("请选择是否为总表!");
                cmbIsSummary.Focus();
                return;
            }
            if (txtWaterMeterIsSummary.Text.Trim() != "")
            {
                if (txtWaterMeterIsSummary.Text.Trim().Length != 8 && txtWaterMeterIsSummary.Text.Trim().Length != 6)
                {
                    mes.Show("总表编号只能为6位用户号或者8位水表编号!");
                    txtWaterMeterIsSummary.Focus();
                    return;
                }
            }
            #endregion

            #region 自动排序
            try
            {
                string strSQL = "UPDATE WATERUSER SET ordernumber=ordernumber+" + intCount + " WHERE areaNO='" + strAreaNO +
                                "' AND pianNO='" + strPianNO + "' AND duanNO='" + strDuanNO + "' AND ordernumber>=" + intOrderNumberStart;

                BLLwaterUser.ExcuteSQL(strSQL);
            }
            catch (Exception ex)
            {
                mes.Show("自动排序失败,批量添加成功后请手动排序!");
            }
            #endregion

            for (int i = 0; i < intCount; i++)
            {
                try
                {
                    MODELWaterUser MODELWaterUser = new MODELWaterUser();
                    //MODELWaterUser.waterUserNO = GETTABLEID.GetTableID("", "WATERUSER");
                    MODELWaterUser.waterUserName          = txtWaterUserName.Text;
                    MODELWaterUser.waterUserNameCode      = txtCode.Text;
                    MODELWaterUser.waterUserAddress       = txtWaterUserAddress.Text;
                    MODELWaterUser.waterUserCerficateType = cmbCerficateType.Text;
                    MODELWaterUser.waterUserCerficateNO   = txtCerficateNO.Text;
                    MODELWaterUser.waterUserTelphoneNO    = txtWaterUserTel.Text;
                    MODELWaterUser.waterPhone             = txtPhone.Text;
                    MODELWaterUser.waterUserPeopleCount   = txtWaterUserCount.Text;
                    MODELWaterUser.areaNO          = cmbAreaNO.Text;
                    MODELWaterUser.pianNO          = cmbPianNO.Text;
                    MODELWaterUser.duanNO          = cmbDuanNO.Text;
                    MODELWaterUser.communityID     = cmbCommunity.SelectedValue.ToString();
                    MODELWaterUser.buildingNO      = txtBuildingNO.Text;
                    MODELWaterUser.unitNO          = txtUnitNO.Text;
                    MODELWaterUser.waterUserTypeId = cmbUserType.SelectedValue.ToString();
                    MODELWaterUser.chargeType      = cmbWaterUserChargeType.SelectedIndex.ToString();

                    MODELWaterUser.waterUserHouseType = cmbUserHouseType.Text;
                    if (MODELWaterUser.waterUserHouseType == "楼房")
                    {
                        MODELWaterUser.waterUserHouseType = "1";
                    }
                    else
                    {
                        MODELWaterUser.waterUserHouseType = "2";
                    }

                    MODELWaterUser.meterReaderID   = cmbMeterReader.SelectedValue.ToString();
                    MODELWaterUser.meterReaderName = cmbMeterReader.Text;

                    MODELWaterUser.chargerID   = cmbCharger.SelectedValue.ToString();
                    MODELWaterUser.chargerName = cmbCharger.Text;

                    //MODELWaterUser.meterReadingID = cmbWaterUserMeterReadingNO.SelectedValue.ToString();
                    //MODELWaterUser.meterReadingPageNo = txtMeterReadingPageNO.Text;
                    MODELWaterUser.ordernumber = intOrderNumberStart + i;

                    MODELWaterUser.agentsign = cmbAgentSign.Text;
                    if (MODELWaterUser.agentsign == "托收")
                    {
                        MODELWaterUser.agentsign        = "1";
                        MODELWaterUser.bankId           = cmbAgentBank.SelectedValue.ToString();
                        MODELWaterUser.BankAcountNumber = txtWaterUserBankNO.Text;
                    }
                    else
                    {
                        MODELWaterUser.agentsign = "2";
                    }

                    MODELWaterUser.createType   = cmbCreateType.Text;
                    MODELWaterUser.MEMO         = txtWaterUserMemo.Text;
                    MODELWaterUser.operatorName = strLogName;

                    MODELWaterUser.waterUserNO         = "U" + (intStartNO + i).ToString().PadLeft(5, '0');
                    MODELWaterUser.waterUserId         = MODELWaterUser.waterUserNO;
                    MODELWaterUser.waterUserCreateDate = mes.GetDatetimeNow();
                    if (BLLwaterUser.InsertwaterUser(MODELWaterUser))
                    {
                        try
                        {
                            MODELwaterMeter MODELwaterMeter = new MODELwaterMeter();
                            //if(cmbWaterMeterPosition.SelectedValue!=null&&cmbWaterMeterPosition.SelectedValue!=DBNull.Value)
                            //    MODELwaterMeter.waterMeterPositionId = cmbWaterMeterPosition.SelectedValue.ToString();
                            MODELwaterMeter.waterMeterPositionName = cmbWaterMeterPosition.Text;
                            MODELwaterMeter.waterMeterSizeId       = cmbWaterMeterSize.SelectedValue.ToString();

                            //如果正常则添加启用时间
                            if (cmbWaterMeterState.Text == "正常")
                            {
                                MODELwaterMeter.waterMeterState  = "1";
                                MODELwaterMeter.STARTUSEDATETIME = mes.GetDatetimeNow();
                            }
                            //if (cmbWaterMeterState.Text == "停水")
                            //    MODELwaterMeter.waterMeterState = "2";
                            //if (cmbWaterMeterState.Text == "报废")
                            MODELwaterMeter.waterMeterState  = (cmbWaterMeterState.SelectedIndex + 1).ToString();
                            MODELwaterMeter.waterMeterTypeId = cmbWaterType.SelectedValue.ToString();

                            MODELwaterMeter.WATERFIXVALUE          = Convert.ToInt32(txtWaterMeterFixedValue.Text);
                            MODELwaterMeter.waterMeterStartNumber  = Convert.ToInt32(txtWaterMeterStartNum.Text);
                            MODELwaterMeter.waterMeterProduct      = txtWaterMeterProductor.Text;
                            MODELwaterMeter.waterMeterSerialNumber = txtWaterMeterSerialNum.Text;
                            MODELwaterMeter.waterMeterMode         = txtWaterMeterModel.Text;
                            MODELwaterMeter.WATERMETERLOCKNO       = txtLockNO.Text;
                            MODELwaterMeter.waterMeterMaxRange     = Convert.ToInt32(txtWaterMeterMaxRange.Text);
                            //if (Information.IsDate(txtWaterMeterProofDate.Text))
                            //    MODELwaterMeter.waterMeterProofreadingDate = Convert.ToDateTime(txtWaterMeterProofDate.Text);
                            MODELwaterMeter.waterMeterProofreadingDate  = dtpProofDate.Value;
                            MODELwaterMeter.waterMeteProofreadingPeriod = Convert.ToInt32(txtProofreadingPeriod.Text);
                            MODELwaterMeter.waterMeterMagnification     = Convert.ToInt32(txtWaterMeterMagnification.Text);
                            MODELwaterMeter.waterUserId        = MODELWaterUser.waterUserId;
                            MODELwaterMeter.isSummaryMeter     = (cmbIsSummary.SelectedIndex + 1).ToString();//分表为1  总表为2
                            MODELwaterMeter.waterMeterParentId = txtWaterMeterIsSummary.Text;

                            MODELwaterMeter.IsReverse = "0";

                            MODELwaterMeter.MEMO         = txtWaterMeterMemo.Text;
                            MODELwaterMeter.waterMeterId = MODELWaterUser.waterUserId + "01";
                            MODELwaterMeter.waterMeterNo = MODELwaterMeter.waterMeterId;
                            //MODELwaterMeter.STARTUSEDATETIME = mes.GetDatetimeNow();
                            if (!BLLwaterMeter.Insert(MODELwaterMeter))
                            {
                                mes.Show("添加用户编号为'" + MODELWaterUser.waterUserId + "'的水表信息时保存失败!请检查填写项目是否符合验证规则!");
                                return;
                            }
                            else
                            {
                                MODELOPERATORLOG MODELOPERATORLOG = new MODELOPERATORLOG();
                                MODELOPERATORLOG.LOGCONTENT = "新增水表:" + MODELwaterMeter.waterMeterId;
                                //MODELOPERATORLOG.METERREADINGID = cmbWaterUserMeterReadingNO.SelectedValue.ToString();
                                MODELOPERATORLOG.LOGTYPE      = "2"; //1代表用户 2代表水表
                                MODELOPERATORLOG.OPERATORID   = strLogID;
                                MODELOPERATORLOG.OPERATORNAME = strLogName;
                                BLLOPERATORLOG.Insert(MODELOPERATORLOG);
                            }
                        }
                        catch (Exception ex)
                        {
                            //回滚用户表
                            BLLwaterUser.DeleteUser(MODELWaterUser.waterUserId);

                            mes.Show(ex.Message);
                            log.Write(ex.ToString(), MsgType.Error);
                            return;
                        }
                    }
                    else
                    {
                        mes.Show("添加用户编号为'" + MODELWaterUser.waterUserId + "'时保存失败!请检查填写项目是否符合验证规则!");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    mes.Show(ex.Message);
                    log.Write(ex.ToString(), MsgType.Error);
                    return;
                }
            }
            DataTable dtList = BLLwaterMeter.QueryConnectWaterUser(" AND WATERUSERID BETWEEN 'U" + intStartNO.ToString().PadLeft(5, '0')
                                                                   + "' AND 'U" + (intStartNO + intCount).ToString().PadLeft(5, '0') + "'");
            dgList.DataSource = dtList;
        }
Ejemplo n.º 7
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (txtWaterUserName.Text.Trim() == "")
            {
                mes.Show("请输入变更后的用户名!");
                txtWaterUserName.Focus();
                return;
            }
            if (mes.ShowQ("确定要将姓名为'" + strWaterUserName + "'的用户名变更为'" + txtWaterUserName.Text + "'吗?") != DialogResult.OK)
            {
                return;
            }

            try
            {
                MODELreadMeterRecord MODELreadMeterRecord = new MODELreadMeterRecord();

                MODELreadMeterRecord.readMeterRecordId = strRecordID;

                MODELreadMeterRecord.waterUserName = txtWaterUserName.Text;

                if (BLLreadMeterRecord.UpdateHandSetWaterUserName(MODELreadMeterRecord))
                {
                    string connectString =
                        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDBFPath + ";Extended Properties=dBASE IV;User ID=Admin;Password=;";
                    string strSQLUpdateWaterMeterType = "UPDATE INTERDB SET yhm='" + MODELreadMeterRecord.waterUserName + "' " +
                                                        " WHERE recordid='" + strRecordID + "'";
                    int intRow = ExcuteSQL(strSQLUpdateWaterMeterType, connectString);
                    if (intRow > 0)
                    {
                        frm.dgList.CurrentRow.Cells["yhm"].Value = MODELreadMeterRecord.waterUserName;
                        //mes.Show("信息变更成功,如果要更改用户基础信息请手动更改!");
                        if (mes.ShowQ("信息变更成功,是否要继续更改用户基础信息?") != DialogResult.OK)
                        {
                            return;
                        }
                        MODELWaterUser MODELWaterUser = new MODELWaterUser();
                        MODELWaterUser.waterUserNO   = strWaterUserNO;
                        MODELWaterUser.waterUserName = MODELreadMeterRecord.waterUserName;
                        if (BLLwaterUser.UpdateHandSetUser(MODELWaterUser))
                        {
                            mes.Show("用户基础信息变更成功!");

                            MODELOPERATORLOG MODELOPERATORLOG = new MODELOPERATORLOG();
                            MODELOPERATORLOG.LOGCONTENT     = "修改用户名:" + strWaterUserName + "→" + txtWaterUserName.Text;
                            MODELOPERATORLOG.METERREADINGID = strMeterReadingID;
                            MODELOPERATORLOG.LOGTYPE        = "3"; //1代表用户 2代表水表 3抄表机
                            MODELOPERATORLOG.OPERATORID     = strLogID;
                            MODELOPERATORLOG.OPERATORNAME   = strUserName;
                            BLLOPERATORLOG.Insert(MODELOPERATORLOG);
                        }
                        else
                        {
                            mes.Show("用户基础信息变更失败,请手动修改户号为'" + strWaterUserNO + "的用户名!");
                            return;
                        }
                    }
                    else
                    {
                        mes.Show("更新抄表数据文件失败,请重试!");
                        return;
                    }
                }
                else
                {
                    mes.Show("更新抄表数据失败,请重试!");
                    return;
                }
            }
            catch (Exception ex)
            {
                mes.Show(ex.Message);
                log.Write(ex.ToString(), MsgType.Error);
            }
        }