예제 #1
0
        protected void loadProductList()
        {
            Dictionary <String, ShopChildProdsInventory> childDict = (Dictionary <String, ShopChildProdsInventory>)
                                                                     Session[SessionFactory.CREATE_INVOICE_MANUAL_PRODUCT_GRID_PRODUCT_LIST];

            if (childDict == null || childDict.Count == 0)
            {
                childDict = ShopChildProdsInventory.
                            getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            }


            foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in childDict)
            {
                ListItem lt = new ListItem();
                lt.Text  = kvp.Key;
                lt.Value = kvp.Value.getUnitListPrice();
                DropDownList_Prod_List.Items.Add(lt);
            }
            ListItem firstItem = new ListItem();

            firstItem.Text  = "_";
            firstItem.Value = "";
            DropDownList_Prod_List.Items.Add(firstItem);

            DropDownList_Prod_List.SelectedValue = "";
        }
예제 #2
0
        protected void fillGrid(String catId)
        {
            if (catId != null && !catId.Equals("") && !catId.Equals("_"))
            {
                DataTable dt = new DataTable();

                dt.Columns.Add("ProdCatId");
                dt.Columns.Add("ProdName");
                dt.Columns.Add("Stock");
                dt.Columns.Add("msrmnt");
                dt.Columns.Add("srcPrice");
                dt.Columns.Add("listPrice");
                dt.Columns.Add("curr");

                Dictionary <String, ShopChildProdsInventory> chilDict = ShopChildProdsInventory.
                                                                        getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                Dictionary <String, Currency> allCurrList = (Dictionary <String, Currency>)Session[SessionFactory.CURRENCY_LIST];

                int counter = 0;

                foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in chilDict)
                {
                    ShopChildProdsInventory childObj = (ShopChildProdsInventory)kvp.Value;

                    if (childObj.getProdCatId().Equals(catId.Trim()) ||
                        BackEndObjects.ProductCategory.getRootLevelParentCategoryDB(childObj.getProdCatId()).ContainsKey(catId.Trim()))
                    {
                        dt.Rows.Add();

                        dt.Rows[counter]["ProdCatId"] = childObj.getProdCatId();
                        dt.Rows[counter]["ProdName"]  = childObj.getProdName();
                        dt.Rows[counter]["Stock"]     = childObj.getQnty();
                        dt.Rows[counter]["msrmnt"]    = childObj.getMsrmntUnit();
                        dt.Rows[counter]["srcPrice"]  = childObj.getUnitSrcPrice();
                        dt.Rows[counter]["listPrice"] = childObj.getUnitListPrice();
                        dt.Rows[counter]["curr"]      = dt.Rows[counter]["curr"] = childObj.getCurrency() != null &&
                                                                                   allCurrList.ContainsKey(childObj.getCurrency()) ?
                                                                                   allCurrList[childObj.getCurrency()].getCurrencyName() : "";

                        counter++;
                    }
                }

                Button_Audit_Prod.Enabled = false;
                Button_Notes_Prod.Enabled = false;
                GridView1.DataSource      = dt;
                GridView1.DataBind();
                GridView1.Visible            = true;
                GridView1.Columns[2].Visible = false;
                GridView1.SelectedIndex      = -1;

                Dictionary <String, bool> accessList = (Dictionary <String, bool>)Session[SessionFactory.ACCESSLIST_FOR_USER];
                if (!accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_EDIT_PRODUCT] &&
                    !accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_OWNER_ACCESS])
                {
                    GridView1.Columns[1].Visible = false;
                }

                Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID] = dt;
            }
            else
            {
                fillGrid();
            }
        }
예제 #3
0
        protected void fillGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("ProdCatId");
            dt.Columns.Add("ProdName");
            dt.Columns.Add("Stock");
            dt.Columns.Add("msrmnt");
            dt.Columns.Add("srcPrice");
            dt.Columns.Add("listPrice");
            dt.Columns.Add("curr");

            Dictionary <String, ShopChildProdsInventory> chilDict = ShopChildProdsInventory.
                                                                    getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
            Dictionary <String, Currency> allCurrList = (Dictionary <String, Currency>)Session[SessionFactory.CURRENCY_LIST];

            //This dictionary will be used by created product screen for duplicacy check
            Dictionary <String, String> allExistingProdDict = new Dictionary <String, String>();

            int counter = 0;

            foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in chilDict)
            {
                dt.Rows.Add();
                ShopChildProdsInventory childObj = (ShopChildProdsInventory)kvp.Value;

                dt.Rows[counter]["ProdCatId"] = childObj.getProdCatId();
                dt.Rows[counter]["ProdName"]  = childObj.getProdName();
                dt.Rows[counter]["Stock"]     = childObj.getQnty();
                dt.Rows[counter]["msrmnt"]    = childObj.getMsrmntUnit();
                dt.Rows[counter]["srcPrice"]  = childObj.getUnitSrcPrice();
                dt.Rows[counter]["listPrice"] = childObj.getUnitListPrice();
                dt.Rows[counter]["curr"]      = childObj.getCurrency() != null &&
                                                allCurrList.ContainsKey(childObj.getCurrency()) ?
                                                allCurrList[childObj.getCurrency()].getCurrencyName() : "";

                if (!allExistingProdDict.ContainsKey(childObj.getProdName()) && !childObj.getProdName().Equals(""))
                {
                    allExistingProdDict.Add(childObj.getProdName(), childObj.getProdName());
                }

                counter++;
            }
            dt.DefaultView.Sort       = "ProdName" + " " + "ASC";
            Button_Audit_Prod.Enabled = false;
            Button_Notes_Prod.Enabled = false;

            GridView1.DataSource = dt.DefaultView.ToTable();
            GridView1.DataBind();
            GridView1.Visible            = true;
            GridView1.Columns[2].Visible = false;
            GridView1.SelectedIndex      = -1;

            Dictionary <String, bool> accessList = (Dictionary <String, bool>)Session[SessionFactory.ACCESSLIST_FOR_USER];

            if (!accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_EDIT_PRODUCT] &&
                !accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_OWNER_ACCESS])
            {
                GridView1.Columns[1].Visible = false;
            }

            Session[SessionFactory.ALL_PRODUCT_CREATE_PRODUCT_EXISTING_NAMES] = allExistingProdDict;
            Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID] = dt.DefaultView.ToTable();
        }
예제 #4
0
        protected void populateChildCategoryDropDown(String catId)
        {
            Dictionary <String, Dictionary <String, String> > prodChildDict = (Dictionary <String, Dictionary <String, String> >)Session["ProductChildCategories"];

            DropDownList_Child_Category.Items.Clear();

            if (prodChildDict == null || prodChildDict.Count == 0 || !prodChildDict.ContainsKey(catId))
            {
                Dictionary <String, ShopChildProdsInventory> childProdDict = ShopChildProdsInventory.
                                                                             getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

                Dictionary <String, String> prodDictForCatId = new Dictionary <string, string>();
                Dictionary <String, String> dupcCheck        = new Dictionary <string, string>();

                ListItem ltFirst = new ListItem();
                ltFirst.Text  = "_";
                ltFirst.Value = "_";
                DropDownList_Child_Category.Items.Add(ltFirst);
                foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in childProdDict)
                {
                    ShopChildProdsInventory prodObj = (ShopChildProdsInventory)kvp.Value;
                    if (prodObj.getProdCatId().Equals(catId.Trim()) ||
                        BackEndObjects.ProductCategory.getRootLevelParentCategoryDB(prodObj.getProdCatId()).ContainsKey(catId.Trim()))
                    {
                        ListItem lt = new ListItem();
                        lt.Text  = ProductCategory.getProductCategorybyIdwoFeaturesDB(prodObj.getProdCatId()).getProductCategoryName();
                        lt.Value = prodObj.getProdCatId();

                        if (!dupcCheck.ContainsKey(lt.Value))
                        {
                            DropDownList_Child_Category.Items.Add(lt);
                            dupcCheck.Add(lt.Value, lt.Text);
                            prodDictForCatId.Add(lt.Text, lt.Value);
                        }
                    }
                }

                if (prodChildDict == null)
                {
                    prodChildDict = new Dictionary <string, Dictionary <string, string> >();
                }

                prodChildDict.Add(catId, prodDictForCatId);
                Session["ProductChildCategories"] = prodChildDict;
            }
            else
            {
                ListItem ltFirst = new ListItem();
                ltFirst.Text  = "_";
                ltFirst.Value = "_";
                DropDownList_Child_Category.Items.Add(ltFirst);

                Dictionary <String, String> childDict = prodChildDict[catId];
                foreach (KeyValuePair <String, String> kvp in childDict)
                {
                    ListItem lt = new ListItem();
                    lt.Text  = kvp.Key;
                    lt.Value = kvp.Value;
                    DropDownList_Child_Category.Items.Add(lt);
                }
            }
            DropDownList_Child_Category.SelectedValue = "_";
        }
예제 #5
0
        protected void createNewProduct()
        {
            Dictionary <String, String> allExistingProdDict = (Dictionary <String, String>)Session[SessionFactory.ALL_PRODUCT_CREATE_PRODUCT_EXISTING_NAMES];

            if (allExistingProdDict.ContainsKey(TextBox_Prod_Name.Text.Trim()))
            {
                Label_Status.Text      = "Product Name Already Exists";
                Label_Status.Visible   = true;
                Label_Status.ForeColor = System.Drawing.Color.Red;
            }
            else if (Session[SessionFactory.CREATE_PRODUCT_SELECTED_PRODUCT_CAT] == null || Session[SessionFactory.CREATE_PRODUCT_SELECTED_PRODUCT_CAT].ToString().Equals(""))
            {
                Label_Status.Text      = "Must select one product category";
                Label_Status.Visible   = true;
                Label_Status.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (!TextBox_Spec.Text.Equals(""))
                {
                    getAddintionalProdSrvList();
                    TextBox_Spec.Text = "";
                }

                ArrayList prodSpecList = (ArrayList)Session[SessionFactory.CREATE_PRODUCT_CHILD_PROD_SPEC_MAP];

                Dictionary <String, String> rSpecUniqnessValidation = new Dictionary <string, string>();
                String mainEntId = Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString();

                if (prodSpecList != null)
                {
                    for (int i = 0; i < prodSpecList.Count; i++)
                    {
                        ShopChildProdsSpecs prodSpecObj = (ShopChildProdsSpecs)prodSpecList[i];

                        prodSpecObj.setProdName(TextBox_Prod_Name.Text);

                        if (rSpecUniqnessValidation.ContainsKey(prodSpecObj.getEntityId() + ":" + prodSpecObj.getProdName() + ":" + prodSpecObj.getFeatId()))
                        {
                            prodSpecList.RemoveAt(i);
                        }
                        else
                        {
                            rSpecUniqnessValidation.Add(prodSpecObj.getEntityId() + ":" + prodSpecObj.getProdName() + ":" + prodSpecObj.getFeatId(), prodSpecObj.getEntityId());
                            if (prodSpecObj != null && prodSpecObj.getFileStream() != null && prodSpecObj.getFileStream().HasFile)
                            {
                                prodSpecObj.setImgPathInFileStore(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                            }
                        }
                    }
                }

                ShopChildProdsInventory childProdObj = new ShopChildProdsInventory();
                childProdObj.setCreatedBy(User.Identity.Name);
                childProdObj.setDateCreated(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                childProdObj.setEntityId(mainEntId);
                childProdObj.setMsrmntUnit(DropDownList_Unit_Of_Msrmnt.SelectedValue);
                childProdObj.setProdCatId(Session[SessionFactory.CREATE_PRODUCT_SELECTED_PRODUCT_CAT].ToString());
                childProdObj.setProdName(TextBox_Prod_Name.Text);
                childProdObj.setQnty((!TextBox_Stock.Text.Equals("")?float.Parse(TextBox_Stock.Text):0));
                childProdObj.setUnitListPrice(TextBox_List_Price.Text);
                childProdObj.setUnitSrcPrice(TextBox_Src_Price.Text);
                childProdObj.setCurrency(DropDownList_Curr.SelectedValue);

                try
                {
                    BackEndObjects.ShopChildProdsInventory.insertShopChildProdsInventoryDB(childProdObj);
                    if (prodSpecList != null)
                    {
                        BackEndObjects.ShopChildProdsSpecs.insertShopChildProdsSpecsListDB(prodSpecList);
                    }

                    //Refresh the session variable with the newly added product name
                    allExistingProdDict.Add(childProdObj.getProdName(), childProdObj.getProdName());
                    Session[SessionFactory.ALL_PRODUCT_CREATE_PRODUCT_EXISTING_NAMES] = allExistingProdDict;

                    Dictionary <String, ProductCategory> existingProdDict = MainBusinessEntity.
                                                                            getProductDetailsforMainEntitybyIdDB(mainEntId);

                    Label_Status.Text                 = "Product/Service Details Created Successfully";
                    Label_Status.Visible              = true;
                    Label_Status.ForeColor            = System.Drawing.Color.Green;
                    DropDownList_Level1.SelectedIndex = -1;
                    DropDownList_Level2.SelectedIndex = -1;
                    DropDownList_Level3.SelectedIndex = -1;


                    if (!existingProdDict.ContainsKey(DropDownList_Level1.SelectedValue))
                    {
                        ArrayList newMainProdCat = new ArrayList();
                        newMainProdCat.Add(DropDownList_Level1.SelectedValue);

                        MainBusinessEntity.insertProductDetailsforEntityDB(mainEntId, newMainProdCat);
                        Label_Status.Text += "...New Product category added to your product list";
                    }

                    DataTable dt = (DataTable)Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID];

                    dt.Rows.Add();
                    int count = dt.Rows.Count - 1;

                    dt.Rows[count]["ProdCatId"] = childProdObj.getProdCatId();
                    dt.Rows[count]["ProdName"]  = childProdObj.getProdName();
                    dt.Rows[count]["Stock"]     = childProdObj.getQnty();
                    dt.Rows[count]["msrmnt"]    = childProdObj.getMsrmntUnit();
                    dt.Rows[count]["srcPrice"]  = childProdObj.getUnitSrcPrice();
                    dt.Rows[count]["listPrice"] = childProdObj.getUnitListPrice();
                    dt.Rows[count]["curr"]      = DropDownList_Curr.SelectedItem.Text;

                    Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID] = dt;
                    ScriptManager.RegisterStartupScript(this, typeof(string), "RefreshProdGrid", "RefreshParent();", true);
                }
                catch (Exception ex)
                {
                    Label_Status.Text      = "Product/Service Details Creation Failed";
                    Label_Status.Visible   = true;
                    Label_Status.ForeColor = System.Drawing.Color.Red;
                }
                finally
                {
                    Session.Remove(SessionFactory.CREATE_PRODUCT_CHILD_PROD_SPEC_MAP);
                    Session.Remove(SessionFactory.CREATE_PRODUCT_SELECTED_PRODUCT_CAT);
                }
            }
        }