Ejemplo n.º 1
0
        private void Insert_Product_From_View()
        {
            DataAccessPOS dbPOS   = new DataAccessPOS();
            int           iTypeId = 0;

            if (cb_ProdType.SelectedItem != null)
            {
                pTypes = dbPOS.Get_ProductTypeId_By_TypeName(cb_ProdType.SelectedItem.ToString());
                if (pTypes.Count == 1)
                {
                    iTypeId = pTypes[0].Id;
                }
            }
            if (String.IsNullOrEmpty(txt_IUnitPrice.Text))
            {
                txt_IUnitPrice.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_OUnitPrice.Text))
            {
                txt_OUnitPrice.Text = "0";
            }

            if (String.IsNullOrEmpty(cb_PromDay1.Text))
            {
                cb_PromDay1.Text = "0";
            }
            if (String.IsNullOrEmpty(cb_PromDay2.Text))
            {
                cb_PromDay2.Text = "0";
            }
            if (String.IsNullOrEmpty(cb_PromDay3.Text))
            {
                cb_PromDay3.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_PromPrice1.Text))
            {
                txt_PromPrice1.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_PromPrice2.Text))
            {
                txt_PromPrice2.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_PromPrice3.Text))
            {
                txt_PromPrice3.Text = "0";
            }

            if (String.IsNullOrEmpty(txt_Deposit.Text))
            {
                txt_Deposit.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_RecyclingFee.Text))
            {
                txt_RecyclingFee.Text = "0";
            }
            if (String.IsNullOrEmpty(txt_ChillCharge.Text))
            {
                txt_ChillCharge.Text = "0";
            }

            if (txt_Memo.Text.Length > 500)
            {
                txt_Memo.Text = txt_Memo.Text.Substring(0, 500);
            }

            prods.Add(new POS_ProductModel()
            {
                ProductName             = txt_ProductName.Text,
                SecondName              = txt_SecondName.Text,
                ProductTypeId           = iTypeId,
                InUnitPrice             = float.Parse(txt_IUnitPrice.Text),
                OutUnitPrice            = float.Parse(txt_OUnitPrice.Text),
                IsTax1                  = checkTax1.Checked,
                IsTax2                  = checkTax2.Checked,
                IsTax3                  = checkTax3.Checked,
                IsTaxInverseCalculation = checkTaxInv.Checked,
                IsPrinter1              = checkPRT1.Checked,
                IsPrinter2              = checkPRT2.Checked,
                IsPrinter3              = checkPRT3.Checked,
                IsPrinter4              = checkPRT4.Checked,
                IsPrinter5              = checkPRT5.Checked,
                PromoStartDate          = dttm_PromStart.Text,
                PromoEndDate            = dttm_PromEnd.Text,
                PromoDay1               = int.Parse(cb_PromDay1.Text),
                PromoDay2               = int.Parse(cb_PromDay2.Text),
                PromoDay3               = int.Parse(cb_PromDay3.Text),
                PromoPrice1             = float.Parse(txt_PromPrice1.Text),
                PromoPrice2             = float.Parse(txt_PromPrice2.Text),
                PromoPrice3             = float.Parse(txt_PromPrice3.Text),
                IsSoldOut               = checkSoldOut.Checked,
                Deposit                 = float.Parse(txt_Deposit.Text),
                RecyclingFee            = float.Parse(txt_RecyclingFee.Text),
                ChillCharge             = float.Parse(txt_ChillCharge.Text),
                MemoText                = txt_Memo.Text
            });
            int iProdCnt = dbPOS.Insert_Product(prods[0]);
        }