public IEnumerable<MaterialFindingModel> SaveMaterial(SessionInfo _session, MaterialFindingModel model)
        {
            //int id = 0;
            string sql = string.Format(@"IF NOT EXISTS
									    (
										    SELECT * FROM ucc_prd_MaterailTracker (NOLOCK)
										    WHERE MaterialTransLineID = {1}
									    )
                                        BEGIN
                                            INSERT INTO ucc_prd_MaterailTracker
                                                       (WorkOrderID
                                                       ,MaterialTransLineID
                                                       ,FoundFlag
                                                       ,UnPackFlag
                                                       ,ProcessFlag
                                                       ,CreationDate
                                                       ,LastUpdateDate
                                                       ,CreatedBy
                                                       ,UpdatedBy)
                                                 VALUES
                                                       ({0}  --<WorkOrderID, bigint,>
                                                       ,{1}  --<MaterialTransLineID, bigint,>
                                                       ,{2}  --<FoundFlag, int,>
                                                       ,{3}  --<UnPackFlag, int,>
                                                       ,{4}  --<ProcessFlag, int,>
                                                       ,GETDATE()  --<CreationDate, datetime,>
                                                       ,GETDATE()  --<LastUpdateDate, datetime,>
                                                       ,N'{5}'  --<CreatedBy, varchar(45),>
                                                       ,N'{5}' --<UpdatedBy, varchar(45),>
		                                    )
                                        END
                                    ELSE
                                        BEGIN
                                            UPDATE ucc_prd_MaterailTracker
                                               SET WorkOrderID = {0}  --<WorkOrderID, bigint,>
                                                  ,FoundFlag = {2}  --<FoundFlag, int,>
                                                  ,UnPackFlag = {3}  --<UnPackFlag, int,>
                                                  ,ProcessFlag = {4}  --<ProcessFlag, int,>
                                                  ,LastUpdateDate = GETDATE()  --<LastUpdateDate, datetime,>
                                                  ,UpdatedBy =  N'{5}' --<UpdatedBy, varchar(45),>
                                             WHERE  MaterialTransLineID = {1} --<Search Conditions,,>
                                        END" + Environment.NewLine
                                              , model.WorkOrderID
                                              , model.TransactionLineID
                                              , Convert.ToInt32(model.FoundFlag.GetBoolean())
                                              , Convert.ToInt32(model.UnPackFlag.GetBoolean())
                                              , Convert.ToInt32(model.ProcessFlag.GetBoolean())
                                              , _session.UserID
                                              );

            //Update PartLot.CheckBox01 = 1 to change status has already used.
//            sql += string.Format(@"UPDATE PartLot SET CheckBox01 = 1, ShortChar05 = N'{2}', Date03 = CONVERT(DATETIME, '{3}',103), Number08 = 2
//                                   WHERE PartNum = N'{0}' AND LotNum = N'{1}'"
//                                   , model.MCSSNo, model.SerialNo, model.WorkOrderNum, model.WorkDate.ToString("dd/MM/yyyy hh:mm:ss"));

            Repository.Instance.ExecuteWithTransaction(sql, "Save Material");
            return GetAllMaterailTracker(_session.PlantID);
        }
Exemple #2
0
        public MaterialTracker(SessionInfo _session = null, string str = null)
        {
            InitializeComponent();
            epiSession = _session;
            _repoWork = new WorkEntryRepo();
            _repo = new MaterialFindingRepo();
            _repoResrc = new ResourceRepo();
            _repoUcode = new UserCodeRepo();

            list = new List<MaterialFindingModel>();
            possessionList = new List<UserCodeModel>();
            resourceList = new List<ResourceModel>();
            modelFilter = new MaterialFindingModel();
        }
        public IEnumerable<MaterialFindingModel> GetAllMaterailTrackerByFilter(string plant, MaterialFindingModel model, IEnumerable<MaterialFindingModel> data = null)
        {
            IEnumerable<MaterialFindingModel> query = data;
            if (query == null) query = this.GetAllMaterailTracker(plant);

            if (!string.IsNullOrEmpty(model.WorkOrderNum)) query = query.Where(p => p.WorkOrderNum.Equals(model.WorkOrderNum.GetString()));
            if (!string.IsNullOrEmpty(model.ProcessLineCode)) query = query.Where(p => p.ProcessLineCode.Equals(model.ProcessLineCode.GetString()));
            //if (!string.IsNullOrEmpty(model.PossessionName)) query = query.Where(p => p.PossessionName.Equals(model.PossessionName.GetString()));
            if (!string.IsNullOrEmpty(model.SpecCode)) query = query.Where(p => p.SpecCode.Equals(model.SpecCode.GetString()));
            if (!string.IsNullOrEmpty(model.CommodityCode)) query = query.Where(p => p.CommodityCode.Equals(model.CommodityCode.GetString()));
            if (!string.IsNullOrEmpty(model.CoatingCode)) query = query.Where(p => p.CoatingCode.Equals(model.CoatingCode.GetString()));

            query = query.Where(p => p.FoundFlag == model.FoundFlag);
            query = query.Where(p => p.UnPackFlag == model.UnPackFlag);
            query = query.Where(p => p.ProcessFlag == model.ProcessFlag);

            return query;
        }
Exemple #4
0
 private void ClearText()
 {
     modelFilter = new MaterialFindingModel();
     txtWorkOrderNum.Text = string.Empty;
     txtSpec.Text = string.Empty;
     txtCommodity.Text = string.Empty;
     txtCoating.Text = string.Empty;
     chkFound.Checked = false;
     chkUnpacked.Checked = false;
     chkProcess.Checked = false;
     cmbProcessLine.Text = "";
     cmbPossession.Text = "";
 }
Exemple #5
0
        private void dgvList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            MaterialFindingModel currentRow = new MaterialFindingModel();

            string workOrderId = dgvList.Rows[e.RowIndex].Cells["workid"].Value.GetString();
            string materialTransID = dgvList.Rows[e.RowIndex].Cells["TransactionLineID"].Value.GetString();

            currentRow = list.Where(i => i.TransactionLineID == Convert.ToInt32(materialTransID)).First();

            if (dgvList.Columns[e.ColumnIndex].Name == "found")//set your check box column index instead of 2
            {
                dgvList.EndEdit();
                DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
                ch1 = (DataGridViewCheckBoxCell)dgvList.Rows[dgvList.CurrentRow.Index].Cells["found"];
                bool checkFound = Convert.ToBoolean(ch1.Value.ToString());
                var result = _repoWork.GetWorkById(epiSession.PlantID, Convert.ToInt32(workOrderId));

                if (result.OperationState == 2 && !checkFound)
                {
                    MessageBox.Show("This material has used to production", "Warning!");
                }
                else if (checkFound)
                {
                    currentRow.FoundFlag = checkFound;
                }
                else if (!checkFound)
                {
                    currentRow.FoundFlag = checkFound;
                }

                var saveResult = _repo.SaveMaterial(epiSession, currentRow);
                list = _repo.GetAllMaterailTrackerByFilter(epiSession.PlantID, modelFilter, list);
                ListMaterialGrid(list);
            }
            else if (dgvList.Columns[e.ColumnIndex].Name == "unpack")
            {
                dgvList.EndEdit();
                DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
                ch1 = (DataGridViewCheckBoxCell)dgvList.Rows[dgvList.CurrentRow.Index].Cells["unpack"];
                bool checkFound = Convert.ToBoolean(ch1.Value.ToString());
                var result = _repoWork.GetWorkById(epiSession.PlantID, Convert.ToInt32(workOrderId));

                if (result.OperationState == 2 && !checkFound)
                {
                    MessageBox.Show("This material has used to production", "Warning!");
                }
                else if (checkFound)
                {
                    currentRow.UnPackFlag = checkFound;
                }
                else if (!checkFound)
                {
                    currentRow.UnPackFlag = checkFound;
                }

                var saveResult = _repo.SaveMaterial(epiSession, currentRow);
                list = _repo.GetAllMaterailTrackerByFilter(epiSession.PlantID, modelFilter, list);
                ListMaterialGrid(list);
            }
        }