Exemple #1
0
        public int UpdateApparatus_quality(EntityApparatus_quality entity)
        {
            string SqlStr = "";

            SqlStr = "update tc_apparatus_quality set ";

            SqlStr += "Apparatus_quality_code = '" + entity.Apparatus_quality_code.Trim() + "', ";
            SqlStr += "Apparatus_output_code = '" + entity.Apparatus_output_code.Trim() + "', ";
            SqlStr += "Apparatus_quality_count = '" + entity.Apparatus_quality_count + "', ";
            SqlStr += "Apparatus_qualityt_issued = '" + entity.Apparatus_qualityt_issued.Trim() + "', ";
            SqlStr += "Apparatus_accident_conditions = '" + entity.Apparatus_accident_conditions.Trim() + "', ";
            SqlStr += "Apparatus_report_date = '" + entity.Apparatus_report_date + "', ";
            SqlStr += "Apparatus_accident_management = '" + entity.Apparatus_accident_management.Trim() + "', ";
            SqlStr += "Apparatus_accident_management_date = '" + entity.Apparatus_accident_management_date + "', ";
            SqlStr += "Apparatus_speaker = '" + entity.Apparatus_speaker.Trim() + "', ";
            SqlStr += "Apparatus_customer_feedback = '" + entity.Apparatus_customer_feedback.Trim() + "', ";
            SqlStr += "Apparatus_opinion_leader = '" + entity.Apparatus_opinion_leader.Trim() + "' ";


            SqlStr += " where Apparatus_quality_code= '" + entity.Apparatus_quality_code.Trim() + "' ";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = SqlStr;

            ExcuteSql(sqlCommand);

            return(Constants.SystemConfig.SERVER_SUCCESS);
        }
        public int InsertApparatus_quality(EntityApparatus_quality entity)
        {
            string SqlStr = "";

            SqlStr  = "insert into tc_apparatus_quality";
            SqlStr += " values('"
                      + entity.Apparatus_quality_code.Trim() + "','"
                      + entity.Apparatus_output_code.Trim() + "','"
                      + entity.Apparatus_quality_count + "','"
                      + entity.Apparatus_qualityt_issued.Trim() + "','"
                      + entity.Apparatus_accident_conditions.Trim() + "','"
                      + entity.Apparatus_report_date + "','"
                      + entity.Apparatus_accident_management.Trim() + "','"
                      + entity.Apparatus_accident_management_date + "','"
                      + entity.Apparatus_speaker.Trim() + "','"
                      + entity.Apparatus_customer_feedback.Trim() + "','"
                      + entity.Apparatus_opinion_leader.Trim() + "')";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = SqlStr;
            try
            {
                ExcuteSql(sqlCommand);
            }
            catch (Exception ex)
            {
                return(Constants.SystemConfig.SERVER_ERROR);

                throw ex;
            }

            return(Constants.SystemConfig.SERVER_SUCCESS);
        }
Exemple #3
0
        //***********************************************************************
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:李梓楠      2010/7/26 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        private void btnCommit_Click(object sender, EventArgs e)
        {
            //判断非法字符
            foreach (Control control in groupBox2.Controls)
            {
                if (control is TextBox)
                {
                    if (Util.CheckRegex(control.Text.Trim()) && !((TextBox)control).ReadOnly)
                    {
                        MessageBox.Show("不可以输入非法字符,请重新输入!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        control.Focus();
                        return;
                    }
                }
            }
            //判断入库编号不为空
            if (txtApparatus_quality_output_code.Text.Trim() == string.Empty || txtApparatus_quality_output_code.Text == "双击选择出库编号...")
            {
                MessageBox.Show("出库编号不能为空!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApparatus_quality_output_code.Focus();
                return;
            }
            if (txtApparatus_quality_count.Text.Trim() == string.Empty)
            {
                MessageBox.Show("出问题产品数量不能为空!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApparatus_quality_count.Focus();
                return;
            }
            if (Convert.ToInt32(txtApparatus_quality_count.Text.Trim()) == 0)
            {
                MessageBox.Show("出问题产品数量不能为0!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApparatus_quality_count.Focus();
                return;
            }
            if (Convert.ToInt32(labelSellcount.Text) < Convert.ToInt32(txtApparatus_quality_count.Text.Trim()))
            {
                MessageBox.Show("输入的数量不能大于出售数量!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                labelSellcount.Focus();
                return;
            }
            if (txtApparatus_speaker.Text.Trim() == string.Empty)
            {
                MessageBox.Show("报告人不能为空!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApparatus_speaker.Focus();
                return;
            }
            if (txtApparatus_qualityt_issued.Text.Trim() == string.Empty || txtApparatus_qualityt_issued.Text == "双击选择经办人...")
            {
                MessageBox.Show("经办人不能为空!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtApparatus_qualityt_issued.Focus();
                return;
            }


            //判断时间有效性
            if (DateTime.Now.Date < dateApparatus_report_date.Value.Date)
            {
                MessageBox.Show("报告日期不能大于今天!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dateApparatus_report_date.Focus();
                return;
            }
            //判断时间有效性
            if (dateApparatus_accident_management_date.Value.Date < dateApparatus_report_date.Value.Date)
            {
                MessageBox.Show("处理日期不能小于报告日期!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dateApparatus_accident_management_date.Focus();
                return;
            }
            //判断时间有效性
            if (dateApparatus_report_date.Value.Date < outputInstorageDate)
            {
                MessageBox.Show("报告日期不能小于销售日期!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            EntityApparatus_quality entity = new EntityApparatus_quality();

            try
            {
                result = -1;

                //如果是添加
                if (dataType == DataType.Insert)
                {
                    entity.Apparatus_output_code              = txtApparatus_quality_output_code.Text;
                    entity.Apparatus_accident_conditions      = txtApparatus_accident_conditions.Text;
                    entity.Apparatus_accident_management      = txtApparatus_accident_management.Text;
                    entity.Apparatus_accident_management_date = dateApparatus_accident_management_date.Value.Date;
                    entity.Apparatus_customer_feedback        = txtApparatus_customer_feedback.Text;
                    entity.Apparatus_opinion_leader           = txtApparatus_opinion_leader.Text;
                    entity.Apparatus_quality_count            = Convert.ToInt32(txtApparatus_quality_count.Text.Trim());
                    entity.Apparatus_qualityt_issued          = txtApparatus_qualityt_issued.Text;
                    entity.Apparatus_report_date              = dateApparatus_report_date.Value.Date;
                    entity.Apparatus_speaker = txtApparatus_speaker.Text;

                    dataAccess = new DataAccess();
                    dataAccess.Open();

                    MakePrimaryKey primaryKey = new MakePrimaryKey(dataAccess.Connection, dataAccess.Transaction);
                    entity.Apparatus_quality_code = primaryKey.MakeCode("器械质量跟踪");

                    GetData getData = new GetData(dataAccess.Connection);
                    result = getData.InsertApparatus_quality(entity);
                    //处理操作标示
                    EntityOutput_storage outputStorageEntity = new EntityOutput_storage();
                    outputStorageEntity.Operate_type = "1";

                    SearchParameter sp = new SearchParameter();
                    sp.SetValue(":output_code", txtApparatus_quality_output_code.Text);
                    result = getData.UpdateOutput_storage(outputStorageEntity, sp);
                }
                //如果是更新
                else if (dataType == DataType.Update)
                {
                    //给选中行赋值
                    countNum = dgv.SelectedRows[0].Index;

                    entity.Apparatus_output_code              = txtApparatus_quality_output_code.Text;
                    entity.Apparatus_accident_conditions      = txtApparatus_accident_conditions.Text;
                    entity.Apparatus_accident_management      = txtApparatus_accident_management.Text;
                    entity.Apparatus_accident_management_date = dateApparatus_accident_management_date.Value.Date;
                    entity.Apparatus_customer_feedback        = txtApparatus_customer_feedback.Text;
                    entity.Apparatus_opinion_leader           = txtApparatus_opinion_leader.Text;
                    entity.Apparatus_quality_count            = Convert.ToInt32(txtApparatus_quality_count.Text.Trim());
                    entity.Apparatus_qualityt_issued          = txtApparatus_qualityt_issued.Text;
                    entity.Apparatus_report_date              = dateApparatus_report_date.Value.Date;
                    entity.Apparatus_speaker      = txtApparatus_speaker.Text;
                    entity.Apparatus_quality_code = dgv.SelectedRows[0].Cells["Apparatus_quality_code"].Value.ToString();

                    dataAccess = new DataAccess();
                    dataAccess.Open();
                    dataAccess.BeginTransaction();

                    GetData getData = new GetData(dataAccess.Connection, dataAccess.Transaction);
                    //取得结果符
                    result = getData.UpdateApparatus_quality(entity);
                    //提交事务
                    dataAccess.Commit();
                }
            }
            catch (Exception ex)
            {
                if (dataAccess.Transaction != null)
                {
                    //回滚
                    dataAccess.Rollback();
                }
                //提示错误
                MessageBox.Show("数据保存时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
            if (result == 0)
            {
                MessageBox.Show("数据已经保存成功!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                BandingDgv();
            }
            else
            {
                MessageBox.Show("数据保存时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //设置按钮状态
            dataType = DataType.None;
            setButtonState();

            //重新加载画面
            BandingDgv();
        }