Exemplo n.º 1
0
        /// <summary>
        /// 删除选中的行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbDelete_Click()
        {
            try
            {
                int j = 0;
                if (this.dgv_SFJC.SelectedRows.Count > 0)//选中删除
                {
                    if (MessageBox.Show("确定要删除吗?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        //选中数量
                        int count = dgv_SFJC.SelectedRows.Count;
                        //遍历
                        for (int i = 0; i < count; i++)
                        {
                            Expression <Func <QCRecord, bool> > funQCRecordinfo = n => n.QCRecord_ID == Convert.ToInt32(dgv_SFJC.SelectedRows[i].Cells["QCRecord_ID"].Value.ToString());

                            if (!QCRecordDAL.DeleteToMany(funQCRecordinfo))
                            {
                                j++;
                            }
                        }
                        if (j == 0)
                        {
                            MessageBox.Show("成功删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        string strContent = "质检记录编号为:" + QCRecord_ID.ToString() + ",删除";
                        LogInfoDAL.loginfoadd("删除", "删除质检记录信息", Common.USERNAME);//添加日志
                    }
                }
                else//没有选中
                {
                    MessageBox.Show("请选择要删除的行!");
                }
            }
            catch (Exception ex)
            {
                Common.WriteTextLog("一检管理详情 tbtnDelUser_delete()+" + ex.Message.ToString());
            }
            finally
            {
                page = new PageControl();
                //LoadData(Name);//更新
                page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
                LoadData();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 对已绑定的单行数据进行修改并保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgv_SFJC.SelectedRows.Count > 1 || iQCRecordId <= 0)
                {
                    MessageBox.Show("修改只能选中一行!");
                }
                else
                {
                    #region 验证文本框
                    if (this.txtQCRecord_RESULT.Text == "")
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "质检结果不能为空!", txtQCRecord_RESULT, this);
                        return;
                    }
                    if (Convert.ToDecimal(this.txtQCRecord_RESULT.Text) == 0)
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "质检结果不能为零!", txtQCRecord_RESULT, this);
                        return;
                    }
                    #endregion

                    #region 找到要修改行信息的位置并进行修改
                    Expression <Func <QCRecord, bool> > p = n => n.QCRecord_ID == iQCRecordId;
                    Action <QCRecord> ap = s =>
                    {
                        s.QCRecord_RESULT  = Convert.ToDecimal(this.txtQCRecord_RESULT.Text.Trim()); //水分值
                        s.QCRecord_NUMBER  = this.txtQCRecord_NUMBER.Text.Trim();                    //质检序号
                        s.QCRecord_DRAW    = Convert.ToDecimal(this.txtQCRecord_DRAW.Text.Trim());   //抽检包号
                        s.QCRecord_TARE    = Convert.ToDecimal(this.txtQCRecord_TARE.Text.Trim());   //预置皮重
                        s.QCRecord_QCCOUNT = Convert.ToInt32(this.txtQCRecord_QCCOUNT.Text.Trim());  //结果质检次数
                        s.QCRecord_COUNT   = this.txtQCRecord_COUNT.Text.Trim();                     //记录质检次数
                    };

                    if (txtQCRecord_RESULT.Text.Substring(0, 1) == ".")
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "第一位不能是小数点!", txtQCRecord_RESULT, this);
                        return;
                    }
                    else
                    {
                        if (QCRecordDAL.Update(p, ap))
                        {
                            MessageBox.Show("修改成功", "提示");
                        }
                        else
                        {
                            MessageBox.Show("修改失败", "提示");
                        }
                    }
                    string strContent = "质检记录编号为:" + QCRecord_ID.ToString() + ",修改";
                    LogInfoDAL.loginfoadd("修改", "修改质检记录信息", Common.USERNAME);//添加日志
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Common.WriteTextLog("手动修改管理 bntUpUser_Click()" + ex.Message.ToString());
            }
            finally
            {
                ClearB();
                LoadData("");
            }
        }