コード例 #1
0
        /// <summary>
        /// 新增一条质检记录
        /// </summary>
        /// <param name="qcRecord">质检实体</param>
        /// <returns></returns>
        public static bool InsertOneQCRecord(PresetTare qcRecord)
        {
            bool rbool = true;

            using (DCQUALITYDataContext db = new DCQUALITYDataContext())
            {
                try
                {
                    db.PresetTare.InsertOnSubmit(qcRecord);
                    db.SubmitChanges();
                    rbool = true;
                }
                catch
                {
                    rbool = false;
                }
                finally { db.Connection.Close(); }
            }
            return(rbool);
        }
コード例 #2
0
        /// <summary>
        /// “添加”按钮的单击事件(添加预置皮重信息)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.txtPresetTare_Weigh.Text == "")
                {
                    mf.ShowToolTip(ToolTipIcon.Info, "提示", "预置皮重不能为空!", txtPresetTare_Weigh, this);
                    return;
                }
                //if (Convert.ToDouble(this.txtPresetTare_Weigh.Text) == 0)
                //{
                //    mf.ShowToolTip(ToolTipIcon.Info, "提示", "预置皮重不能为零!", txtPresetTare_Weigh, this);
                //    return;
                //}
                if (selectIsHave(txtPresetTare_Name.Text) == false)
                {
                    mf.ShowToolTip(ToolTipIcon.Info, "提示", "预置皮重名称重复!", txtPresetTare_Weigh, this);
                    return;
                }
                //ValidateTextBox();//调用验证文本框方法
                if (!btnCheck())
                {
                    return;             //去重
                }
                var presetTradeadd = new PresetTare
                {
                    PresetTare_Dictionary_ID = Convert.ToInt32(this.cbxPresetTareState.SelectedValue),
                    PresetTare_NAME          = this.txtPresetTare_Name.Text.Trim(),
                    PresetTare_WEIGH         = Convert.ToDecimal(this.txtPresetTare_Weigh.Text.Trim()),
                    PresetTare_REMARK        = this.txtPresetTare_Remark.Text.Trim()
                };

                if (txtPresetTare_Weigh.Text.Substring(0, 1) == ".")
                {
                    mf.ShowToolTip(ToolTipIcon.Info, "提示", "第一位不能是小数点!", txtPresetTare_Weigh, this);
                }
                else
                {
                    if (PresetTareDAL.InsertOneQCRecord(presetTradeadd))
                    {
                        MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        mf.ShowToolTip(ToolTipIcon.Info, "提示", "不能同时输入两位以上的小数点(包含两位)!", txtPresetTare_Weigh, this);
                    }
                }


                string strContent = "预置皮重名称为:" + this.txtPresetTare_Name.Text.Trim();
                Common.WriteLogData("新增", "新增 " + strContent + " 的信息", Common.USERNAME);
            }
            catch (Exception ex)
            {
                Common.WriteTextLog("预置皮重管理 btnAdd_Click()" + ex.Message.ToString());
                // mf.ShowToolTip(ToolTipIcon.Info, "提示", "预置皮重输入格式错误!", txtPresetTare_Weigh, this);
            }
            finally
            {
                page = new PageControl();
                page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString();
                LoadData();
            }
        }