private void insertItem(string category, string cust, string itemCode, string itemName, string Material, string MB, string Color)
        {
            //Add data
            itemBLL u = new itemBLL();

            u.item_cat = category;



            u.item_code = itemCode;
            u.item_name = itemName;

            u.item_material = Material;
            u.item_mb       = MB;
            u.item_color    = Color;

            u.item_quo_ton  = 0;
            u.item_best_ton = 0;
            u.item_pro_ton  = 0;

            u.item_quo_ct      = 0;
            u.item_pro_ct_from = 0;
            u.item_pro_ct_to   = 0;
            u.item_capacity    = 0;

            u.item_quo_pw_pcs = 0;
            u.item_quo_rw_pcs = 0;
            u.item_pro_pw_pcs = 0;
            u.item_pro_rw_pcs = 0;

            u.item_pro_pw_shot     = 0;
            u.item_pro_rw_shot     = 0;
            u.item_pro_cooling     = 0;
            u.item_wastage_allowed = 0.05f;

            u.item_assembly   = 0;
            u.item_production = 0;


            u.item_added_date = DateTime.Now;
            u.item_added_by   = MainDashboard.USER_ID;

            //Inserting Data into Database
            bool success = dalItem.NewInsert(u);

            //If the data is successfully inserted then the value of success will be true else false
            if (success)
            {
                //Data Successfully Inserted
                //MessageBox.Show("Item successfully created");

                pairCustomer(cust, itemCode);
            }
            else
            {
                //Failed to insert data
                MessageBox.Show("Failed to add new item");
            }
        }
        public frmItemEdit(itemBLL u)
        {
            InitializeComponent();

            loadItemCategoryData();
            loadMaterialTypeData();
            loadMasterBatchData();
            InitialData(u);
            inputDisable();
        }
        private void updateItem(string category, string cust, string itemCode, string itemName, string Material, string MB, string Color)
        {
            //Update data
            itemBLL u = new itemBLL();

            u.item_cat  = category;
            u.item_code = itemCode;
            u.item_name = itemName;

            u.item_material = Material;
            u.item_mb       = MB;
            u.item_color    = Color;

            u.item_quo_ton  = 0;
            u.item_best_ton = 0;
            u.item_pro_ton  = 0;

            u.item_quo_ct      = 0;
            u.item_pro_ct_from = 0;
            u.item_pro_ct_to   = 0;
            u.item_capacity    = 0;

            u.item_quo_pw_pcs = 0;
            u.item_quo_rw_pcs = 0;
            u.item_pro_pw_pcs = 0;
            u.item_pro_rw_pcs = 0;

            u.item_pro_pw_shot     = 0;
            u.item_pro_rw_shot     = 0;
            u.item_pro_cooling     = 0;
            u.item_wastage_allowed = 0.05f;

            u.item_assembly   = 0;
            u.item_production = 0;


            u.item_updtd_date = DateTime.Now;
            u.item_updtd_by   = MainDashboard.USER_ID;
            //Updating data into database
            //bool success = dalItem.Update(u);
            bool success = dalItem.NewUpdate(u);

            //if data is updated successfully then the value = true else false
            if (success == true)
            {
                //data updated successfully
                //MessageBox.Show("Item successfully updated ");
                pairCustomer(cust, itemCode);
            }
            else
            {
                //failed to update user
                MessageBox.Show("Failed to updated item");
            }
        }
Ejemplo n.º 4
0
        public item GetItem(string objectId)
        {
            itemBLL bll = new itemBLL();

            try
            {
                var model = bll.QuerySingleById(objectId);
                return(model);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        private void InitialData(itemBLL u)
        {
            if (!string.IsNullOrEmpty(u.item_code))
            {
                cmbCat.Text      = u.item_cat;
                txtItemCode.Text = u.item_code;
                txtItemName.Text = u.item_name;

                cmbMaterialType.Text = u.item_material;
                cmbMasterBatch.Text  = u.item_mb;
                txtMBRate.Text       = u.item_mb_rate.ToString();
                txtColor.Text        = u.item_color;

                txtQuoTon.Text  = u.item_quo_ton.ToString();
                txtBestTon.Text = u.item_best_ton.ToString();
                txtProTon.Text  = u.item_pro_ton.ToString();

                txtQuoCT.Text     = u.item_quo_ct.ToString();
                txtProCTFrom.Text = u.item_pro_ct_from.ToString();
                txtProCTTo.Text   = u.item_pro_ct_to.ToString();
                txtCapacity.Text  = u.item_capacity.ToString();
                txtQuoPWPcs.Text  = u.item_quo_pw_pcs.ToString();
                txtQuoRWPcs.Text  = u.item_quo_rw_pcs.ToString();
                txtProPWPcs.Text  = u.item_pro_pw_pcs.ToString();
                txtProRWPcs.Text  = u.item_pro_rw_pcs.ToString();

                txtProPWShot.Text      = u.item_pro_pw_shot.ToString();
                txtProRWShot.Text      = u.item_pro_rw_shot.ToString();
                txtProCooling.Text     = u.item_pro_cooling.ToString();
                txtWastageAllowed.Text = u.item_wastage_allowed.ToString();

                if (u.item_assembly.ToString() != null)
                {
                    if (u.item_assembly == 1)
                    {
                        cbAssembly.Checked = true;
                    }
                    else
                    {
                        cbAssembly.Checked = false;
                    }
                }
                else
                {
                    cbAssembly.Checked = false;
                }

                if (u.item_production.ToString() != null)
                {
                    if (u.item_production == 1)
                    {
                        cbProduction.Checked = true;
                    }
                    else
                    {
                        cbProduction.Checked = false;
                    }
                }
                else
                {
                    cbProduction.Checked = false;
                }


                if (!dalItem.getCatName(u.item_code).Equals("Part"))
                {
                    if (dalMaterial.checkIfZeroCost(u.item_code))
                    {
                        cbZeroCost.Checked = true;
                    }
                    else
                    {
                        cbZeroCost.Checked = false;
                    }
                }
            }
            else
            {
                cmbCat.Text = u.item_cat;
                InitialData();
            }
        }
        private void insertItem()
        {
            //Add data
            itemBLL u = new itemBLL();

            u.item_cat = cmbCat.Text;

            if (!join)
            {
                itemParentCode = txtItemCode.Text;
                parentCust     = cmbCust.Text;
            }
            else
            {
                itemChildCode = txtItemCode.Text;
            }

            u.item_code = txtItemCode.Text;
            u.item_name = txtItemName.Text;

            u.item_material = cmbMat.Text;
            u.item_mb       = cmbMB.Text;
            u.item_color    = txtColor.Text;

            u.item_quo_ton  = 0;
            u.item_best_ton = 0;
            u.item_pro_ton  = 0;

            u.item_quo_ct      = 0;
            u.item_pro_ct_from = 0;
            u.item_pro_ct_to   = 0;
            u.item_capacity    = tool.Int_TryParse(txtCapacity.Text);

            u.item_quo_pw_pcs = tool.Float_TryParse(txtQuoPWpcs.Text);
            u.item_quo_rw_pcs = tool.Float_TryParse(txtQuoRWpcs.Text);
            u.item_pro_pw_pcs = tool.Float_TryParse(txtPWpcs.Text);
            u.item_pro_rw_pcs = tool.Float_TryParse(txtRWpcs.Text);

            u.item_pro_pw_shot     = tool.Float_TryParse(txtPWshot.Text);
            u.item_pro_rw_shot     = tool.Float_TryParse(txtRWshot.Text);
            u.item_pro_cooling     = 0;
            u.item_wastage_allowed = 0.05f;

            if (cbAssembly.Checked)
            {
                u.item_assembly = 1;
            }
            else
            {
                u.item_assembly = 0;
            }

            if (cbProduction.Checked)
            {
                u.item_production = 1;
            }
            else
            {
                u.item_production = 0;
            }

            u.item_added_date = DateTime.Now;
            u.item_added_by   = MainDashboard.USER_ID;

            //Inserting Data into Database
            bool success = dalItem.NewInsert(u);

            //If the data is successfully inserted then the value of success will be true else false
            if (success)
            {
                //Data Successfully Inserted
                //MessageBox.Show("Item successfully created");
                if (!join)
                {
                    pairCustomer();
                }
            }
            else
            {
                //Failed to insert data
                MessageBox.Show("Failed to add new item");
            }
        }
        private void updateItem()
        {
            //Update data
            itemBLL u = new itemBLL();

            u.item_cat = cmbCat.Text;

            if (!join)
            {
                itemParentCode = txtItemCode.Text;
                parentCust     = cmbCust.Text;
            }
            else
            {
                itemChildCode = txtItemCode.Text;
            }

            u.item_code = txtItemCode.Text;
            u.item_name = txtItemName.Text;

            u.item_material = cmbMat.Text;
            u.item_mb       = cmbMB.Text;
            u.item_color    = txtColor.Text;

            u.item_quo_ton  = 0;
            u.item_best_ton = 0;
            u.item_pro_ton  = 0;

            u.item_quo_ct      = 0;
            u.item_pro_ct_from = 0;
            u.item_pro_ct_to   = 0;
            u.item_capacity    = tool.Int_TryParse(txtCapacity.Text);

            u.item_quo_pw_pcs = tool.Float_TryParse(txtQuoPWpcs.Text);
            u.item_quo_rw_pcs = tool.Float_TryParse(txtQuoRWpcs.Text);
            u.item_pro_pw_pcs = tool.Float_TryParse(txtPWpcs.Text);
            u.item_pro_rw_pcs = tool.Float_TryParse(txtRWpcs.Text);

            u.item_pro_pw_shot     = tool.Float_TryParse(txtPWshot.Text);
            u.item_pro_rw_shot     = tool.Float_TryParse(txtRWshot.Text);
            u.item_pro_cooling     = 0;
            u.item_wastage_allowed = 0.05f;

            if (cbAssembly.Checked)
            {
                u.item_assembly = 1;
            }
            else
            {
                u.item_assembly = 0;
            }

            if (cbProduction.Checked)
            {
                u.item_production = 1;
            }
            else
            {
                u.item_production = 0;
            }

            u.item_updtd_date = DateTime.Now;
            u.item_updtd_by   = MainDashboard.USER_ID;
            //Updating data into database
            //bool success = dalItem.Update(u);
            bool success = dalItem.NewUpdate(u);

            //if data is updated successfully then the value = true else false
            if (success == true)
            {
                //data updated successfully
                MessageBox.Show("Item successfully updated ");
                if (!join)
                {
                    pairCustomer();
                }
            }
            else
            {
                //failed to update user
                //MessageBox.Show("Failed to updated item");
            }
        }