예제 #1
0
 public void SetMaterialRemain(MaterialModel mat)
 {
     RemainWidthOpt1 = mat.Width - SimReshears.Where(i => i.OptionNum == 1 && i.MaterialTransLineID == mat.TransactionLineID).Sum(i => i.WidthActualRemain);
     RemainWidthOpt2 = mat.Width - SimReshears.Where(i => i.OptionNum == 2 && i.MaterialTransLineID == mat.TransactionLineID).Sum(i => i.WidthActualRemain);
     RemainLengthOpt1 = mat.Length - SimReshears.Where(i => i.OptionNum == 1 && i.MaterialTransLineID == mat.TransactionLineID).Sum(i => i.LengthActualRemain);
     RemainLengthOpt2 = mat.Length - SimReshears.Where(i => i.OptionNum == 2 && i.MaterialTransLineID == mat.TransactionLineID).Sum(i => i.LengthActualRemain);
 }
예제 #2
0
        public void CalculateRowForLegnthOption(MaterialModel mat)
        {
            foreach (var m in Materials.Where(i => i.TransactionLineID.Equals(mat.TransactionLineID)))
            {
                var line = Cuttings.Where(i => i.CutDiv.Equals(CutSeleted) && i.MaterialSerialNo.GetString() == m.SerialNo && i.CalculatedFlag.GetBoolean() == true);
                if (m.UsedFlag && line.ToList().Count == 0)
                {
                    m.UsingLengthM = m.UsingLengthM + Expected;
                }
                else
                {
                    m.UsingLengthM = Expected;
                }
                //m.UsedFlag = true;
            }

            foreach (var item in Cuttings.Where(i => i.CutDiv.Equals(CutSeleted)))
            {
                item.CalculateRow(this, mat);
            }

            SumProductWeight();
            SumMaterialWeight();
            SumYeild();
        }
예제 #3
0
 public MaterialSelecting(SessionInfo _session, IEnumerable<MaterialModel> data, PlanningHeadModel workOrder)
 {
     InitializeComponent();
     this._repo = new WorkEntryRepo();
     epiSession = _session;
     this.model = data;
     this._selected = new MaterialModel();
     this.baseOrder = workOrder;
 }
예제 #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="material"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 public bool ValidateToDelMaterial(MaterialModel material, out string msg)
 {
     bool valid = true;
     msg = "";
     //TODO : Work around method.
     /*
      * Condition statement...
     */
     return valid;
 }
예제 #5
0
        private bool CheckCoilBackState(MaterialModel param)
        {
            //Get coil-back existing row by TransactionLineID.
            var result = (from item in HeaderContent.CoilBacks
                          where item.TransactionLineID == param.TransactionLineID
                          select item).FirstOrDefault();

            //If remain-weight greater than zero will be to add/modify coil-back.
            if (param.RemainWeight > 0)
            {
                return true;
            }
            //Will be to delete coil-back.
            else if (param.RemainWeight == 0 && result != null)
            {
                return false;
            }
            //Nothing else to delete coil-back.
            else
            {
                return false;
            }
        }
예제 #6
0
        private bool UpdateCoilBack(MaterialModel result, bool chk)
        {
            bool bolResult = false;
            if (chk)
            {
                #region Bind data.

                result.CBSelect = true;
                CoilBackModel CBack = new CoilBackModel();
                CBack.WorkOrderID = HeaderContent.WorkOrderID;
                CBack.TransactionLineID = result.TransactionLineID;
                CBack.CommodityCode = result.CommodityCode;
                CBack.SpecCode = result.SpecCode;
                CBack.CoatingCode = result.CoatingCode;
                CBack.Thick = result.Thick;
                CBack.Width = result.Width;
                CBack.Length = result.Length;
                CBack.Weight = result.RemainWeight;
                CBack.Qty = result.RemainQuantity;
                CBack.MCSSNo = result.MCSSNo;
                CBack.OldSerial = result.SerialNo;
                CBack.Gravity = result.Gravity;
                CBack.FrontPlate = result.FrontPlate;
                CBack.BackPlate = result.BackPlate;
                CBack.Status = result.Status;
                CBack.BussinessType = result.BussinessType;
                CBack.Possession = result.Possession;
                CBack.ProductStatus = Convert.ToInt32(result.ProductStatus);
                CBack.Note = "Add manual";

                #endregion Bind data.

                HeaderContent.CoilBacks = _repo.SaveCoilBack(epiSession, CBack).ToList();
                bolResult = true;
            }
            else if (!chk)
            {
                HeaderContent.CoilBacks = _repo.DeleteCoilBack(epiSession, HeaderContent.WorkOrderID, result.TransactionLineID).ToList();
                bolResult = false;
            }

            return bolResult;
        }
예제 #7
0
 public decimal CalculateUnitWeightOptionLM(MaterialModel mat)
 {
     return (mat.Weight * LengthM) / mat.LengthM;
 }
예제 #8
0
        public void CalculateRow(SimulateActionModel head, MaterialModel mat)
        {
            //Fix bug in case Materials is null.
            //if (head.SimulateOption == 0)
            //{
            decimal widthMat = 0;
            decimal cutMax = 0;
            widthMat = mat.Width;
            cutMax = head.Cuttings.Max(i => i.CutDiv);
            UnitWeight = Math.Round(CalUnitWgtByUsingWgt(head.Expected, widthMat, Width), 2);
            TotalWeight = UnitWeight * Stand;
            LengthM = Math.Round(CalLengthMeter(UnitWeight, Width, Thick, Gravity, FrontPlate, BackPlate), 0);
            //}
            //else if (head.SimulateOption == 1)
            //{
            //    LengthM = mat.UsingLengthM;
            //    UnitWeight = (mat.Weight * LengthM) / mat.LengthM;
            //}

            CalculatedFlag = true;
            MCSSNum = mat.MCSSNo;
            TransactionLineID = mat.TransactionLineID;
            MaterialSerialNo = mat.SerialNo;
        }
예제 #9
0
        private void butSelect_Click(object sender, EventArgs e)
        {
            if (dgvMaterial.Rows.Count >= 1)
            {
                int iRow = dgvMaterial.CurrentRow.Index;
                string mcssno = dgvMaterial.Rows[iRow].Cells["MCSSNum"].Value.ToString();
                string lotno = dgvMaterial.Rows[iRow].Cells["article"].Value.ToString();

                if (!string.IsNullOrEmpty(mcssno))
                {
                    _selected = _repo.GetMaterial(epiSession.PlantID, mcssno, lotno);
                    _selected.WorkOrderID = baseOrder.WorkOrderID;
                    _selected.WorkOrderNum = baseOrder.WorkOrderNum;
                    _selected.WorkDate = baseOrder.IssueDate;
                    _selected.SetQuantityPack();
                    _selected.SetUsingWeight();
                    _selected.SetUsingQuantity();
                    var result = _repo.SaveMaterial(epiSession, _selected);
                }

                this.Close();
            }
        }
예제 #10
0
        /// <summary>
        /// Must be call PlanningHeadModel.ValidateToDelMaterial
        /// </summary>
        /// <param name="_session">Type of current session login</param>
        /// <param name="model">Type of material selected to delete</param>
        /// <param name="msg">Out put result messege from this</param>
        /// <returns>true = success/false = unsuccess</returns>
        public bool DeleteMaterail(Models.SessionInfo _session, MaterialModel model, out string msg)
        {
            msg = "";
            try
            {
                string sql = string.Format(@"DELETE FROM ucc_pln_Material WHERE TransactionLineID = {0}", model.TransactionLineID);

                sql += string.Format(@"UPDATE PartLot SET CheckBox01 = 0, ShortChar05 = '', Date03 = null , Number08 = 1
                                        WHERE PartNum = N'{0}' AND LotNum = N'{1}'"
                                           , model.MCSSNo, model.SerialNo);

                Repository.Instance.ExecuteWithTransaction(sql, "Delete Material");
                return true;
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return false;
            }
        }
예제 #11
0
        /// <summary>
        /// Save a material for each WorkOrder.
        /// </summary>
        /// <param name="_session"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public MaterialModel SaveMaterial(Models.SessionInfo _session, MaterialModel model)
        {
            //int id = 0;
            string sql = string.Format(@"IF NOT EXISTS
									    (
										    SELECT * FROM ucc_pln_Material (NOLOCK)
										    WHERE TransactionLineID = {29}
									    )
                                        BEGIN
                                            INSERT INTO ucc_pln_Material
                                               (Company
                                               ,Plant
                                               ,WorkOrderID
                                               ,MatSeq
                                               ,Serial
                                               ,Cmdty
                                               ,Spec
                                               ,Coating
                                               ,Category
                                               ,Thick
                                               ,Width
                                               ,Length
                                               ,Weight
                                               ,UsingWgt
                                               ,RemainWgt
                                               ,Qty
                                               ,RemainQty
                                               ,LenghtM
                                               ,UsingLM
                                               ,SelectCB
                                               ,CBalready
                                               ,MCSSNo
                                               ,Status
                                               ,BT
                                               ,Possession
                                               ,ProductSts
                                               ,Descriptions
                                               ,Note
                                               ,CreationDate
                                               ,LastUpdateDate
                                               ,CreatedBy
                                               ,UpdatedBy)
                                            VALUES
                                               ( N'{0}' --<Company, nvarchar(8),>
                                               , N'{1}' --<Plant, nvarchar(8),>
                                               , {2} --<WorkOrderID, bigint,>
                                               , {3} --<MatSeq, int,>
                                               , N'{4}' --<Serial, nvarchar(18),>
                                               , N'{5}' --<Cmdty, nvarchar(10),>
                                               , N'{6}' --<Spec, nvarchar(10),>
                                               , N'{7}' --<Coating, nvarchar(10),>
                                               , N'{8}' --<Category, nvarchar(10),>
                                               , {9} --<Thick, decimal(20,9),>
                                               , {10} --<Width, decimal(20,9),>
                                               , {11} --<Length, decimal(20,9),>
                                               , {12} --<Weight, decimal(20,9),>
                                               , {13} --<UsingWgt, decimal(20,9),>
                                               , {14} --<RemainWgt, decimal(20,9),>
                                               , {15} --<Qty, decimal(20,9),>
                                               , {16} --<RemainQty, decimal(20,9),>
                                               , {17} --<LenghtM, decimal(20,9),>
                                               , {18} --<UsingLM, decimal(20,9),>
                                               , {19} --<SelectCB, tinyint,>
                                               , {20} --<CBalready, tinyint,>
                                               , N'{21}' --<MCSSNo, nvarchar(18),>
                                               , N'{22}' --<Status, nvarchar(10),>
                                               , N'{23}' --<BT, nvarchar(10),>
                                               , {24} --<Possession, int,>
                                               , N'{25}' --<ProductSts, nvarchar(10),>
                                               , N'{26}' --<Descriptions, varchar(500),>
                                               , N'{27}' --<Note, varchar(500),>
                                               , GETDATE() --<CreationDate, datetime,>
                                               , GETDATE() --<LastUpdateDate, datetime,>
                                               , N'{28}' --<CreatedBy, varchar(45),>
                                               , N'{28}' --<UpdatedBy, varchar(45),>
		                                    )
                                        END
                                    ELSE
                                        BEGIN
                                            UPDATE ucc_pln_Material
                                               SET UsingWgt = {13} --<UsingWgt, decimal(20,9),>
                                                  ,RemainWgt = {14} --<RemainWgt, decimal(20,9),>
                                                  ,Qty = {15} --<Qty, decimal(20,9),>
                                                  ,RemainQty = {16} --<RemainQty, decimal(20,9),>
                                                  ,LenghtM = {17} --<LenghtM, decimal(20,9),>
                                                  ,UsingLM = {18} --<UsingLM, decimal(20,9),>
                                                  ,SelectCB = {19} --<SelectCB, tinyint,>
                                                  ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,>
                                                  ,UpdatedBy = N'{28}' --<UpdatedBy, varchar(45),>
                                             WHERE TransactionLineID = {29}
                                        END" + Environment.NewLine
                                              , _session.CompanyID
                                              , _session.PlantID
                                              , model.WorkOrderID
                                              , 1 //model.Seq
                                              , model.SerialNo
                                              , model.CommodityCode     //{5}
                                              , model.SpecCode
                                              , model.CoatingCode
                                              , ""
                                              , model.Thick
                                              , model.Width         //{10}
                                              , model.Length
                                              , model.Weight
                                              , model.UsingWeight
                                              , model.RemainWeight
                                              , model.UsingQuantity      //{15}
                                              , model.RemainQuantity
                                              , model.LengthM
                                              , model.UsingLengthM
                                              , Convert.ToInt32(model.CBSelect.GetBoolean())
                                              , Convert.ToInt32(model.CBalready.GetBoolean())   //{20}
                                              , model.MCSSNo
                                              , model.Status
                                              , model.BussinessType
                                              , model.Possession
                                              , model.ProductStatus         //{25}
                                              , model.PrdDescriptions
                                              , model.Note
                                              , _session.UserID
                                              , model.TransactionLineID
                                              );

            //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, "Add Material");
            return GetMaterial(_session.PlantID, model.MCSSNo, model.SerialNo);
        }