Exemplo n.º 1
0
 public M_Products Selectm_Product(M_Products objm_Product)
 {
     try
     {
         strquery = @"select * from M_Products where IDX = '" + objm_Product.IDX + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objm_Product.IDX                = drType["IDX"].ToString();
             objm_Product.Compcode           = drType["Compcode"].ToString();
             objm_Product.Locacode           = drType["Locacode"].ToString();
             objm_Product.Namex              = drType["Namex"].ToString();
             objm_Product.PrintName          = drType["PrintName"].ToString();
             objm_Product.Category           = drType["Category"].ToString();
             objm_Product.Make               = drType["Make"].ToString();
             objm_Product.Model              = drType["Model"].ToString();
             objm_Product.Brand              = drType["Brand"].ToString();
             objm_Product.Color              = drType["Color"].ToString();
             objm_Product.Unitx              = drType["Unitx"].ToString();
             objm_Product.Suplier            = drType["Suplier"].ToString();
             objm_Product.UnitPrice          = decimal.Parse(drType["UnitPrice"].ToString());
             objm_Product.SellingPrice       = decimal.Parse(drType["SellingPrice"].ToString());
             objm_Product.CostPrice          = decimal.Parse(drType["CostPrice"].ToString());
             objm_Product.ReorderQTY         = decimal.Parse(drType["ReorderQTY"].ToString());
             objm_Product.ReorderLevel       = decimal.Parse(drType["ReorderLevel"].ToString());
             objm_Product.MaxDisc            = decimal.Parse(drType["MaxDisc"].ToString());
             objm_Product.MinDisc            = decimal.Parse(drType["MinDisc"].ToString());
             objm_Product.ApplyingDisc       = decimal.Parse(drType["ApplyingDisc"].ToString());
             objm_Product.LockItem           = bool.Parse(drType["LockItem"].ToString());
             objm_Product.IsActive           = bool.Parse(drType["IsActive"].ToString());
             objm_Product.FrezzItem          = bool.Parse(drType["FrezzItem"].ToString());
             objm_Product.DiscountAllowed    = bool.Parse(drType["DiscountAllowed"].ToString());
             objm_Product.SalesCommAllowed   = bool.Parse(drType["SalesCommAllowed"].ToString());
             objm_Product.NegativeQTY        = bool.Parse(drType["NegativeQTY"].ToString());
             objm_Product.VatApplicable      = bool.Parse(drType["VatApplicable"].ToString());
             objm_Product.Norefundable       = bool.Parse(drType["Norefundable"].ToString());
             objm_Product.OpenPrice          = bool.Parse(drType["OpenPrice"].ToString());
             objm_Product.StockLot           = bool.Parse(drType["StockLot"].ToString());
             objm_Product.isOpenPrice        = bool.Parse(drType["isOpenPrice"].ToString());
             objm_Product.IsMaintainStockLot = bool.Parse(drType["IsMaintainStockLot"].ToString());
             objm_Product.WholesalePrice     = decimal.Parse(drType["WholesalePrice"].ToString());
             objm_Product.SupplierWarrenty   = decimal.Parse(drType["SupplierWarrenty"].ToString());
             objm_Product.CustomerWarrenty   = decimal.Parse(drType["CustomerWarrenty"].ToString());
             objm_Product.CommissionAmount   = decimal.Parse(drType["CommissionAmount"].ToString());
             objm_Product.CommissionPer      = decimal.Parse(drType["CommissionPer"].ToString());
             objm_Product.CreateUser         = drType["CreateUser"].ToString();
             objm_Product.CreateDate         = DateTime.Parse(drType["CreateDate"].ToString());
             objm_Product.ModifyUser         = drType["ModifyUser"].ToString();
             objm_Product.ModifyDate         = DateTime.Parse(drType["ModifyDate"].ToString());
             objm_Product.SubCategory        = drType["SubCategory"].ToString();
             objm_Product.AutoIndex          = int.Parse(drType["AutoIndex"].ToString());
             return(objm_Product);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        public static decimal GetSellingPrice(string code)
        {
            decimal dec = decimal.Zero;

            if (M_ProductDL.ExistingM_Product(code))
            {
                M_Products pro = new M_Products();
                pro.IDX = code;
                pro     = new M_ProductDL().Selectm_Product(pro);
                dec     = decimal.Round(pro.SellingPrice.Value, 2);
            }
            return(dec);
        }
Exemplo n.º 3
0
        public static decimal GetProductSellingPrice(string ProductID)
        {
            decimal stock = decimal.Zero;

            try
            {
                M_Products stk = new M_Products();
                stk.IDX = ProductID;

                stk   = new M_ProductDL().Selectm_Product(stk);
                stock = stk.SellingPrice.Value;
            }
            catch (Exception ex)
            {
            }
            return(stock);
        }
Exemplo n.º 4
0
        public static string FindExisitingProduct(string locacode)
        {
            string str = "";

            if (M_ProductDL.ExistingM_Product(locacode.Trim()))
            {
                M_Products cat = new M_Products();
                cat.IDX = locacode.Trim();
                M_ProductDL dl = new M_ProductDL();
                cat = dl.Selectm_Product(cat);
                str = cat.Namex;
            }
            else
            {
                str = "<Error!!!>";
            }
            return(str);
        }
        private void txt_code_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                if (ActiveControl.Name.Trim() == txt_code.Name.Trim())
                {
                    int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["ProductFieldLength"]);
                    string[] strSearchField = new string[length];

                    string strSQL = ConfigurationManager.AppSettings["ProductSQL"].ToString();

                    for (int i = 0; i < length; i++)
                    {
                        string m;
                        m = i.ToString();
                        strSearchField[i] = ConfigurationManager.AppSettings["ProductField" + m + ""].ToString();
                    }

                    frmU_Search find = new frmU_Search(strSQL, strSearchField, this);
                    find.ShowDialog(this);
                }

                //FindExisitingSupplier();
                errorProvider1.Clear();
            }

            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    //txt_code.Text = commonFunctions.GetProcutCode(txt_code.Text.Trim());
                    if (T_StockDL.ExistingT_Stock_Product(txt_code.Text, commonFunctions.GlobalCompany, commonFunctions.GlobalLocation))
                    {
                        if (!commonFunctions.IsExistINV(dataGridView1, txt_code.Text))
                        {
                            M_Products stk = new M_Products();
                            stk.Locacode = commonFunctions.GlobalLocation;
                            stk.Compcode = commonFunctions.GlobalCompany;
                            stk.IDX      = txt_code.Text;
                            stk          = new M_ProductDL().Selectm_Product(stk);

                            txt_cost.Text    = stk.CostPrice.ToString();
                            txt_selling.Text = stk.SellingPrice.ToString();
                            lbl_name.Text    = stk.Namex;

                            txt_qty.Text = "0";
                            txt_qty.Focus();

                            errorProvider1.Clear();
                            already = false;
                        }
                        else
                        {
                            already = true;
                            //errorProvider1.SetError(txt_code, "Already exists");
                            M_Products stk = new M_Products();
                            stk.Locacode = commonFunctions.GlobalLocation;
                            stk.Compcode = commonFunctions.GlobalCompany;
                            stk.IDX      = txt_code.Text;
                            stk          = new M_ProductDL().Selectm_Product(stk);

                            txt_cost.Text    = stk.CostPrice.ToString();
                            txt_selling.Text = stk.SellingPrice.ToString();
                            lbl_name.Text    = stk.Namex;

                            DataGridViewRow drowx = new DataGridViewRow();
                            drowx = commonFunctions.GetRow(dataGridView1, txt_code.Text.Trim());

                            txt_qty.Text = drowx.Cells["Quntity"].Value.ToString();

                            txt_qty.Focus();
                        }
                    }
                    else
                    {
                        errorProvider1.SetError(txt_code, "Product you have entered not exist in the product master file");
                        commonFunctions.SetMDIStatusMessage("Product you have entered not exist in the product master file", 1);
                    }
                }
                catch (Exception ex)
                {
                    LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                    commonFunctions.SetMDIStatusMessage("Genaral Error", 2);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Saves a record to the M_Products table.
        /// </summary>
        public Boolean SaveM_ProductSP(M_Products m_Product, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "M_ProductsSave";

                scom.Parameters.Add("@IDX", SqlDbType.VarChar, 20).Value             = m_Product.IDX;
                scom.Parameters.Add("@Compcode", SqlDbType.VarChar, 20).Value        = m_Product.Compcode;
                scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value        = m_Product.Locacode;
                scom.Parameters.Add("@Namex", SqlDbType.VarChar, 150).Value          = m_Product.Namex;
                scom.Parameters.Add("@PrintName", SqlDbType.VarChar, 150).Value      = m_Product.PrintName;
                scom.Parameters.Add("@Category", SqlDbType.VarChar, 30).Value        = m_Product.Category;
                scom.Parameters.Add("@Make", SqlDbType.VarChar, 30).Value            = m_Product.Make;
                scom.Parameters.Add("@Model", SqlDbType.VarChar, 30).Value           = m_Product.Model;
                scom.Parameters.Add("@Brand", SqlDbType.VarChar, 30).Value           = m_Product.Brand;
                scom.Parameters.Add("@Color", SqlDbType.VarChar, 30).Value           = m_Product.Color;
                scom.Parameters.Add("@Unitx", SqlDbType.VarChar, 30).Value           = m_Product.Unitx;
                scom.Parameters.Add("@Suplier", SqlDbType.VarChar, 30).Value         = m_Product.Suplier;
                scom.Parameters.Add("@UnitPrice", SqlDbType.Decimal, 9).Value        = m_Product.UnitPrice;
                scom.Parameters.Add("@SellingPrice", SqlDbType.Decimal, 9).Value     = m_Product.SellingPrice;
                scom.Parameters.Add("@CostPrice", SqlDbType.Decimal, 9).Value        = m_Product.CostPrice;
                scom.Parameters.Add("@ReorderQTY", SqlDbType.Decimal, 9).Value       = m_Product.ReorderQTY;
                scom.Parameters.Add("@ReorderLevel", SqlDbType.Decimal, 9).Value     = m_Product.ReorderLevel;
                scom.Parameters.Add("@MaxDisc", SqlDbType.Decimal, 9).Value          = m_Product.MaxDisc;
                scom.Parameters.Add("@MinDisc", SqlDbType.Decimal, 9).Value          = m_Product.MinDisc;
                scom.Parameters.Add("@ApplyingDisc", SqlDbType.Decimal, 9).Value     = m_Product.ApplyingDisc;
                scom.Parameters.Add("@LockItem", SqlDbType.Bit, 1).Value             = m_Product.LockItem;
                scom.Parameters.Add("@IsActive", SqlDbType.Bit, 1).Value             = m_Product.IsActive;
                scom.Parameters.Add("@FrezzItem", SqlDbType.Bit, 1).Value            = m_Product.FrezzItem;
                scom.Parameters.Add("@DiscountAllowed", SqlDbType.Bit, 1).Value      = m_Product.DiscountAllowed;
                scom.Parameters.Add("@SalesCommAllowed", SqlDbType.Bit, 1).Value     = m_Product.SalesCommAllowed;
                scom.Parameters.Add("@NegativeQTY", SqlDbType.Bit, 1).Value          = m_Product.NegativeQTY;
                scom.Parameters.Add("@VatApplicable", SqlDbType.Bit, 1).Value        = m_Product.VatApplicable;
                scom.Parameters.Add("@Norefundable", SqlDbType.Bit, 1).Value         = m_Product.Norefundable;
                scom.Parameters.Add("@OpenPrice", SqlDbType.Bit, 1).Value            = m_Product.OpenPrice;
                scom.Parameters.Add("@StockLot", SqlDbType.Bit, 1).Value             = m_Product.StockLot;
                scom.Parameters.Add("@isOpenPrice", SqlDbType.Bit, 1).Value          = m_Product.isOpenPrice;
                scom.Parameters.Add("@IsMaintainStockLot", SqlDbType.Bit, 1).Value   = m_Product.IsMaintainStockLot;
                scom.Parameters.Add("@WholesalePrice", SqlDbType.Decimal, 9).Value   = m_Product.WholesalePrice;
                scom.Parameters.Add("@SupplierWarrenty", SqlDbType.Decimal, 9).Value = m_Product.SupplierWarrenty;
                scom.Parameters.Add("@CustomerWarrenty", SqlDbType.Decimal, 9).Value = m_Product.CustomerWarrenty;
                scom.Parameters.Add("@CommissionAmount", SqlDbType.Decimal, 9).Value = m_Product.CommissionAmount;
                scom.Parameters.Add("@CommissionPer", SqlDbType.Decimal, 9).Value    = m_Product.CommissionPer;
                scom.Parameters.Add("@CreateUser", SqlDbType.VarChar, 20).Value      = m_Product.CreateUser;
                scom.Parameters.Add("@CreateDate", SqlDbType.DateTime, 8).Value      = m_Product.CreateDate;
                scom.Parameters.Add("@ModifyUser", SqlDbType.VarChar, 20).Value      = m_Product.ModifyUser;
                scom.Parameters.Add("@ModifyDate", SqlDbType.DateTime, 8).Value      = m_Product.ModifyDate;
                scom.Parameters.Add("@SubCategory", SqlDbType.VarChar, 20).Value     = m_Product.SubCategory;
                scom.Parameters.Add("@AutoIndex", SqlDbType.Int, 4).Value            = m_Product.AutoIndex;
                scom.Parameters.Add("@InsMode", SqlDbType.Int).Value  = formMode; // For insert
                scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0;

                u_DBConnection dbcon = new u_DBConnection();
                retvalue = dbcon.RunQuery(scom);
                return(retvalue);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }