Пример #1
0
        private void butConfirm_Click(object sender, EventArgs e)
        {
            decimal d;
            if (!decimal.TryParse(txtHH.Text.GetString(), out d))
            {
                MessageBox.Show("Data type not valid.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtHH.Focus();
                return;
            }

            if (!decimal.TryParse(txtMM.Text.GetString(), out d))
            {
                MessageBox.Show("Data type not valid.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMM.Focus();
                return;
            }

            if (!decimal.TryParse(txtSS.Text.GetString(), out d))
            {
                MessageBox.Show("Data type not valid.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSS.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtRemark.Text))
            {
                MessageBox.Show("Please fill reason.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRemark.Focus();
                return;
            }

            if (string.IsNullOrEmpty(HeaderContent.CutSeqStr))
            {
                MessageBox.Show("Please fill cut seq.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbCutLine.Focus();
                return;
            }

            string duratTime = string.Format("{0}:{1}:{2}", txtHH.Text, txtMM.Text, txtSS.Text);
            if (duratTime != "00:00:00")
            {
                LineStopModel model = new LineStopModel();
                model.ProductionID = HeaderContent.ProductionID;
                model.WorkOrderID = HeaderContent.WorkOrderID;
                model.StopCode = HeaderContent.Reason;
                model.Description = txtRemark.Text;
                model.DurationTime = duratTime;
                model.CutSeq = Convert.ToDecimal(HeaderContent.CutSeqStr);

                if (_repo.SaveLineStop(epiSession, model))
                {
                    timer2.Enabled = false;
                    SetTimeControl("Confirm");
                }
            }
        }
Пример #2
0
        public bool SaveLineStop(SessionInfo _session, LineStopModel model)
        {
            string sql = string.Format(@"INSERT INTO ucc_prd_LineStop
                                                    (ProductionID
                                                    ,WorkOrderID
                                                    ,StopCode
                                                    ,Description
                                                    ,DurationTime
                                                    ,CreationDate
                                                    ,LastUpdateDate
                                                    ,CreatedBy
                                                    ,UpdatedBy
                                                    ,CutSeq)
                                                VALUES
                                                    ({0} --<ProductionID, bigint,>
                                                    ,{1} --<WorkOrderID, bigint,>
                                                    ,N'{2}' --<StopCode, nvarchar(45),>
                                                    ,N'{3}' --<Description, nvarchar(max),>
                                                    ,N'{4}' --<DurationTime, nvarchar(45),>
                                                    ,GETDATE() --<CreationDate, datetime,>
                                                    ,GETDATE() --<LastUpdateDate, datetime,>
                                                    ,N'{5}' --<CreatedBy, varchar(45),>
                                                    ,N'{5}' --<UpdatedBy, varchar(45),>
                                                    ,{6} --<CutSeq, int,>
		                                            )"
                /*
                                        ELSE
                                            BEGIN
                                                UPDATE ucc_prd_LineStop
                                                   SET ProductionID = {0} --<ProductionID, bigint,>
                                                      ,WorkOrderID = {1} --<WorkOrderID, bigint,>
                                                      ,StopCode = N'{2}' --<StopCode, nvarchar(45),>
                                                      ,Description = N'{3}' --<Description, nvarchar(max),>
                                                      ,DurationTime = N'{5}' --<DurationTime, nvarchar(45),>
                                                      ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,>
                                                      ,UpdatedBy = N'{5}' --<UpdatedBy, varchar(45),>
                                                 WHERE WorkOrderID = {1} AND ProductionID = {0}
                                            END"
                 */
                                            + Environment.NewLine
                                              , model.ProductionID
                                              , model.WorkOrderID
                                              , model.StopCode
                                              , model.Description
                                              , model.DurationTime
                                              , _session.UserID
                                              , model.CutSeq);

            try
            {
                Repository.Instance.ExecuteWithTransaction(sql, "Save Line Stop");
                return true;
            }
            catch
            {
                return false;
            }
        }