Exemplo n.º 1
0
        public int UpdateLoseTable(EntityLose entity)
        {
            string SqlStr = "";

            SqlStr = "update tc_lose set ";

            SqlStr += "input_code = '" + entity.Input_code.Trim() + "' ,";
            SqlStr += "lose_count = '" + entity.Lose_count + "', ";
            SqlStr += "lose_reason = '" + entity.Lose_reason.Trim() + "' ,";
            SqlStr += "lose_applier = '" + entity.Lose_applier.Trim() + "' ,";
            SqlStr += "lose_checker = '" + entity.Lose_checker.Trim() + "' ,";
            SqlStr += "lose_datetime = '" + entity.Lose_datetime + "' ,";
            SqlStr += "lose_result = '" + entity.Lose_result.Trim() + "' ,";
            SqlStr += "lose_remark = '" + entity.Lose_remark.Trim() + "' ";

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

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = SqlStr;

            ExcuteSql(sqlCommand);

            return(Constants.SystemConfig.SERVER_SUCCESS);
        }
Exemplo n.º 2
0
        public int InsertLoseRow(EntityLose entity)
        {
            string SqlStr = "";

            SqlStr  = "insert into tc_lose(lose_code,input_code,lose_count,lose_reason,lose_applier,lose_checker,lose_datetime,lose_result,lose_remark)";
            SqlStr += " values('" + entity.Lose_code.Trim() + "','" + entity.Input_code.Trim() + "','" + entity.Lose_count + "','" + entity.Lose_reason.Trim() + "','" + entity.Lose_applier.Trim() + "','" + entity.Lose_checker.Trim() + "','" + entity.Lose_datetime + "','" + entity.Lose_result.Trim() + "','" + entity.Lose_remark.Trim() + "')";

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.CommandText = SqlStr;

            ExcuteSql(sqlCommand);

            return(Constants.SystemConfig.SERVER_SUCCESS);
        }
Exemplo n.º 3
0
        //***********************************************************************
        /// <summary>
        /// 确认按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        ///    完成信息:代国明      2010/07/25 完成
        ///    更新信息:
        /// </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("不可以输入非法字符,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        control.Focus();
                        return;
                    }
                }
            }

            //条件不为空
            if (txt_input_code.Text.Trim() == string.Empty || txt_input_code.Text.Trim() == "双击选择入库编号...")
            {
                MessageBox.Show("入库编号不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_input_code.Focus();
                return;
            }

            if (txt_goods_name.Text.Trim() == string.Empty)
            {
                MessageBox.Show("产品编号不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_goods_name.Focus();
                return;
            }

            //判断时间有效性
            if (DateTime.Now.Date < dtp_lose_datetime.Value.Date)
            {
                MessageBox.Show("报损日期不能大于今天!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dtp_lose_datetime.Focus();
                return;
            }
            if (instorageDate > dtp_lose_datetime.Value.Date)
            {
                MessageBox.Show("报损日期不能小于入库日期!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dtp_lose_datetime.Focus();
                return;
            }

            if (txt_lose_applier.Text.Trim() == "双击选择报损申请人..." || txt_lose_applier.Text.Trim() == string.Empty)
            {
                MessageBox.Show("报损申请人不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_lose_applier.Focus();
                return;
            }

            if (txt_lose_checker.Text.Trim() == "双击选择报损核准人..." || txt_lose_checker.Text.Trim() == string.Empty)
            {
                MessageBox.Show("报损核准人不能为空!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_lose_checker.Focus();
                return;
            }

            //添加,修改后库存数目剪掉添加数目数据信息
            UpdateStorageDetailsByAdd();

            try
            {
                result = -1;

                //如果是添加
                if (dataType == DataType.Insert)
                {
                    //取得实体类
                    loseEntity = new EntityLose();

                    //赋值实体类
                    loseEntity.Input_code    = txt_input_code.Text.ToString();
                    loseEntity.Lose_applier  = txt_lose_applier.Text.ToString();
                    loseEntity.Lose_checker  = txt_lose_checker.Text.ToString();
                    loseEntity.Lose_count    = int.Parse(nud_lose_count.Value.ToString());
                    loseEntity.Lose_reason   = txt_lose_reason.Text.ToString();
                    loseEntity.Lose_remark   = txt_lose_remark.Text.ToString();
                    loseEntity.Lose_result   = txt_lose_result.Text.ToString();
                    loseEntity.Lose_datetime = Convert.ToDateTime(dtp_lose_datetime.Value.ToString("yyyy-MM-dd"));

                    //赋值实体类
                    inputStorageEntity = new EntityInput_storage();
                    inputStorageEntity.OPERATE_TYPE = '1';
                    inputStorageEntity.INPUT_CODE   = txt_input_code.Text.ToString();

                    //打开数据库连接
                    dataAccess = new DataAccess();
                    dataAccess.Open();

                    //取得操作类
                    GetData getData = new GetData(dataAccess.Connection);

                    //生成主键
                    MakePrimaryKey mpk = new MakePrimaryKey(dataAccess.Connection, dataAccess.Transaction);

                    loseEntity.Lose_code = mpk.MakeCode("报损表");

                    //取得结果符
                    result = getData.InsertLoseRow(loseEntity);

                    if (result == 0)
                    {
                        MessageBox.Show("数据已经保存成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("数据已经保存失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    getData.UpdateOperate_typeByInput_codeRow(inputStorageEntity);
                }
            }
            catch (Exception ex)
            {
                if (dataAccess.Transaction != null)
                {
                    //回滚
                    dataAccess.Rollback();
                }

                //提示错误
                MessageBox.Show("数据时发生错误,请检查数据库!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }

            //设置按钮状态
            dataType = DataType.None;
            setButtonState();

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