コード例 #1
0
 /// <summary>
 /// 单击保存按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtWeighInfo_Name.Text.Trim()))
         {
             MessageBox.Show("请输入地磅房名称");
             return;
         }
         if (string.IsNullOrEmpty(cobWeighInfo_State.Text.Trim()))
         {
             MessageBox.Show("请选择启动状态");
             return;
         }
         if (txtRemark.Text.Trim().Length > 200)
         {
             MessageBox.Show("超过最大字符,限制200字内");
             return;
         }
         //查重
         DataSet ds = LinQBaseDao.Query("select COUNT(1) from WeighInfo where WeighInfo_Name='" + txtWeighInfo_Name.Text.Trim() + "'");
         if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
         {
             MessageBox.Show("该磅房名称已存在");
             return;
         }
         //进行新增操作
         WeighInfo info = new WeighInfo();
         info.WeighInfo_Name       = txtWeighInfo_Name.Text.Trim();
         info.WeighInfo_Phone      = txtWeighInfo_Phone.Text.Trim();
         info.WeighInfo_State      = cobWeighInfo_State.Text.Trim();
         info.WeighInfo_CreateTime = CommonalityEntity.GetServersTime();
         info.WeighInfo_Remark     = txtRemark.Text.Trim();
         if (WeighInfoDAL.InsertOneCamera(info))
         {
             MessageBox.Show("保存成功");
             CommonalityEntity.WriteLogData("新增", "新增过磅基础信息:" + txtWeighInfo_Name.Text.Trim(), CommonalityEntity.USERNAME);//添加操作日志
             Empty();
         }
         else
         {
             MessageBox.Show("保存失败");
         }
     }
     catch
     {
         Console.WriteLine("");
     }
     finally
     {
         LogInfoLoad("");
     }
 }
コード例 #2
0
        /// <summary>
        /// 新增一条质检记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneCamera(WeighInfo eh_Fvn)
        {
            bool rbool = true;

            using (DCCarManagementDataContext db = new DCCarManagementDataContext())
            {
                try
                {
                    rbool = LinQBaseDao.InsertOne(db, eh_Fvn);
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
コード例 #3
0
 /// <summary>
 /// 单击修改按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnupdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvWeighInfo.SelectedRows.Count > 0)//选中行
         {
             if (dgvWeighInfo.SelectedRows.Count > 1)
             {
                 MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             else
             {
                 //进行修改
                 WeighInfo info = new WeighInfo();
                 if (string.IsNullOrEmpty(txtWeighInfo_Name.Text.Trim()))
                 {
                     MessageBox.Show("地磅房名称不能为空");
                     return;
                 }
                 if (string.IsNullOrEmpty(cobWeighInfo_State.Text.Trim()))
                 {
                     MessageBox.Show("请选择启动状态");
                     return;
                 }
                 if (dgvWeighInfo.SelectedRows[0].Cells["WeighInfo_Name"].Value.ToString() != txtWeighInfo_Name.Text.Trim())
                 {
                     //查重
                     DataSet ds = LinQBaseDao.Query("select COUNT(1) from WeighInfo where WeighInfo_Name='" + txtWeighInfo_Name.Text.Trim() + "'");
                     if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0)
                     {
                         MessageBox.Show("该磅房名称已存在");
                         Empty();
                         return;
                     }
                 }
                 Expression <Func <WeighInfo, bool> > p = n => n.WeighInfo_ID == int.Parse(this.dgvWeighInfo.SelectedRows[0].Cells["WeighInfo_ID"].Value.ToString());
                 Action <WeighInfo> ap = s =>
                 {
                     s.WeighInfo_Name   = txtWeighInfo_Name.Text.Trim();
                     s.WeighInfo_Phone  = this.txtWeighInfo_Phone.Text.Trim();
                     s.WeighInfo_State  = this.cobWeighInfo_State.Text.Trim();
                     s.WeighInfo_Remark = this.txtRemark.Text.Trim();
                 };
                 if (WeighInfoDAL.Update(p, ap))
                 {
                     MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Empty();
                 }
                 else
                 {
                     MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
         }
     }
     catch
     {
         CommonalityEntity.WriteTextLog("地磅房信息管理 btnupdate_Click()" + "".ToString());
     }
     finally
     {
         LogInfoLoad("");
     }
 }