예제 #1
0
        public IEnumerable<SpecialRef> DeleteSpecailRef(SpecialRef model)
        {
            string sql = string.Format(@"DELETE FROM ucc_tqa_McssSpecialRef WHERE LineID = {0}" + Environment.NewLine, model.RefId);

            Repository.Instance.ExecuteWithTransaction(sql, "Delete Specail Ref");
            return GetSpecialRefByMCSS(model.McssNum);
        }
예제 #2
0
 private void butDeleteLine_Click(object sender, EventArgs e)
 {
     if (dgvList.Rows.Count == 1) return;
     int iRow = dgvList.CurrentRow.Index;
     SpecialRef m = new SpecialRef();
     m.RefId = int.Parse(dgvList.Rows[iRow].Cells["id"].Value.GetString());
     m.McssNum = McssContent.McssNum;
     McssContent.SpecialRefs = _repo.DeleteSpecailRef(m);
     specialRef.Clear();
     SetGrid(McssContent.SpecialRefs);
 }
예제 #3
0
        public IEnumerable<SpecialRef> SaveSpecailRef(SpecialRef model, Models.SessionInfo epiSession, Dictionary<int, string> Refs)
        {
            foreach (var pair in Refs)
            {
                string sql = string.Format(@"IF NOT EXISTS
									    (
										    SELECT * FROM ucc_tqa_McssSpecialRef (NOLOCK)
										    WHERE  LineNum = {2} AND MCSSNum = N'{1}'
									    )
									    BEGIN
                                            INSERT INTO ucc_tqa_McssSpecialRef
                                                   (Plant
                                                   ,MCSSNum
                                                   ,LineNum
                                                   ,Description
                                                   ,CreationDate
                                                   ,LastUpdateDate
                                                   ,CreatedBy
                                                   ,UpdatedBy)
                                             VALUES
                                                   (N'{0}' --<Plant, nvarchar(18),>
                                                   ,N'{1}' --<MCSSNum, nvarchar(100),>
                                                   ,{2}  --<LineNum, int,>
                                                   ,N'{3}' --<Description, nvarchar(max),>
                                                   ,GETDATE() --<CreationDate, datetime,>
                                                   ,GETDATE() --<LastUpdateDate, datetime,>
                                                   ,N'{4}' --<CreatedBy, nvarchar(45),>
                                                   ,N'{4}' --<UpdatedBy, nvarchar(45),>)
                                                 )
                                        END
                                        ELSE
                                        BEGIN
                                            UPDATE ucc_tqa_McssSpecialRef
                                               SET Description = N'{3}' 
                                                  ,LastUpdateDate = GETDATE()
                                                  ,UpdatedBy = N'{4}'
                                             WHERE  LineNum = {2} AND MCSSNum = N'{1}'
                                        END" + Environment.NewLine,
                                                                epiSession.PlantID,
                                                                model.McssNum,
                                                                pair.Key,
                                                                pair.Value,
                                                                epiSession.UserID);

                Repository.Instance.ExecuteWithTransaction(sql, "Update Specail Ref");
            }
            return GetSpecialRefByMCSS(model.McssNum);
        }
예제 #4
0
        private void tlbSave_Click(object sender, EventArgs e)
        {
            bool IsSucces = false;
            string msg = "";
            MCSS model = new MCSS();

            //model.McssNum = txtMcssNum.Text.Trim();
            model.Thick = Convert.ToDecimal(txtThick.Text);
            model.Width = Convert.ToDecimal(txtWidth.Text);
            model.Length = Convert.ToDecimal(txtLength.Text);

            McssContent.Pocession = (rdoPocession0.Checked) ?  0 : 1;

            var dupRecord = _repo.GetByFilter(DateTime.Now, DateTime.Now, model, false);
            int i = 1;

            if (dupRecord.ToList().Count > 0)
            {
                foreach (var p in dupRecord)
                {
                    if (p.McssNum != txtMcssNum.Text.Trim())
                    {
                        msg += i + ". " + p.McssNum + "\t (" + p.CommodityCode + " : " + p.CommodityName + ") \t" + p.Size + Environment.NewLine;
                        i++;
                    }
                }
                if (i > 1)
                {
                    if (MessageBox.Show("Already exists Spec in table." + Environment.NewLine + msg + "Do you want to save?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            if (ValidatingContent(out msg) == false)
            {
                var result = _repo.Save(McssContent, epiSession, out IsSucces, out msg);

                if (IsSucces)
                {
                    SpecialRef modelRef = new SpecialRef();
                    modelRef.McssNum = McssContent.McssNum;
                    result.SpecialRefs = _repo.SaveSpecailRef(modelRef, epiSession, specialRef);
                    McssContent = result;
                    specialRef.Clear();
                    SetContent(McssContent);
                }
                else
                {
                    MessageBox.Show(msg, "Warnning.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("List of invalid field." + Environment.NewLine + msg, "Invalid field.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }