Exemplo n.º 1
0
        private void LoadOptions()
        {
            ProductGroup clsProductGroup = new ProductGroup();
            DataClass    clsDataClass    = new DataClass();

            cboGroup.DataTextField  = "ProductGroupName";
            cboGroup.DataValueField = "ProductGroupID";
            cboGroup.DataSource     = clsProductGroup.ListAsDataTable(SortField: "ProductGroupName").DefaultView;
            cboGroup.DataBind();
            cboGroup.SelectedIndex = cboGroup.Items.Count - 1;

            Data.Unit clsUnit = new Data.Unit();

            cboProductSubGroupUnit.DataTextField  = "UnitName";
            cboProductSubGroupUnit.DataValueField = "UnitID";
            cboProductSubGroupUnit.DataSource     = clsUnit.ListAsDataTable(SortField: "UnitName").DefaultView;
            cboProductSubGroupUnit.DataBind();
            cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.Count - 1;

            clsUnit.CommitAndDispose();

            if (cboGroup.Items.Count != 0)
            {
                Int32 BaseUnitID = clsProductGroup.Details(Convert.ToInt32(cboGroup.SelectedItem.Value)).UnitDetails.UnitID;
                cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.IndexOf(cboProductSubGroupUnit.Items.FindByValue(BaseUnitID.ToString()));
            }
            clsProductGroup.CommitAndDispose();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            const string defaultHeading = "Master Files";
            string       stHeading      = defaultHeading;

            const string defaultTitle = "List of Product Sub Group Variation Combinations";

            SiteTitle.Title = defaultTitle;

            const SearchCategoryID defaultSearchIndex = SearchCategoryID.ProductSubGroups;
            SearchCategoryID       SearchIndex        = defaultSearchIndex;

            HorizontalNavBar.PageNavigatorid = HorizontalNavID.MasterFiles;

            if (Request.QueryString["task"] != null)
            {
                ProductGroup        clsProductGroup = new ProductGroup();
                ProductGroupDetails clsDetails      = new ProductGroupDetails();

                int id = Convert.ToInt16(Common.Decrypt(Request.QueryString["subgroupid"].ToString(), Session.SessionID));
                clsDetails = clsProductGroup.Details(id);

                clsProductGroup.CommitAndDispose();
                string groupCode = " for Product Sub Group Code : " + clsDetails.ProductGroupName;

                string task = Common.Decrypt(Request.QueryString["task"].ToString(), Session.SessionID);
                switch (task)
                {
                case "add":
                    stHeading          = "Create New Product Sub Group Variation Combination";
                    SearchIndex        = SearchCategoryID.ProductVariations;
                    ctrlInsert.Visible = true;
                    break;

                case "edit":
                    stHeading          = "Modify Product Sub Group Variation Combination";
                    SearchIndex        = SearchCategoryID.ProductVariations;
                    ctrlUpdate.Visible = true;
                    break;

                case "list":
                    stHeading        = "Product Sub Group Variation Combinations List";
                    SearchIndex      = SearchCategoryID.ProductVariations;
                    ctrlList.Visible = true;
                    break;

                case "details":
                    stHeading           = "Sub Group Variation Details";
                    SearchIndex         = SearchCategoryID.ProductVariations;
                    ctrlDetails.Visible = true;
                    break;

                default:
                    break;
                }

                LargeHeading.Text = stHeading + groupCode;
                RightBodySectionSearch.SearchIDSelectedItem = SearchIndex;
            }
        }
Exemplo n.º 3
0
        private void LoadOptions()
        {
            DataClass clsDataClass = new DataClass();

            lblGroupID.Text  = Common.Decrypt((string)Request.QueryString["groupid"], Session.SessionID);
            lblMatrixID.Text = Common.Decrypt(Request.QueryString["id"], Session.SessionID);

            ProductGroupVariations clsProductGroupVariation = new ProductGroupVariations();

            lstItem.DataSource = clsDataClass.DataReaderToDataTable(clsProductGroupVariation.List(Convert.ToInt32(lblGroupID.Text), "VariationType", SortOption.Ascending)).DefaultView;
            lstItem.DataBind();
            clsProductGroupVariation.CommitAndDispose();

            Data.Unit clsUnit = new Data.Unit();
            cboUnit.DataTextField  = "UnitName";
            cboUnit.DataValueField = "UnitID";
            cboUnit.DataSource     = clsUnit.ListAsDataTable(SortField: "UnitName").DefaultView;
            cboUnit.DataBind();
            cboUnit.SelectedIndex = cboUnit.Items.Count - 1;
            clsUnit.CommitAndDispose();

            ProductGroup        clsProductGroup        = new ProductGroup();
            ProductGroupDetails clsProductGroupDetails = clsProductGroup.Details(Convert.ToInt32(lblGroupID.Text));

            cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsProductGroupDetails.UnitDetails.UnitID.ToString()));
            txtProductPrice.Text  = clsProductGroupDetails.Price.ToString("#,##0.#0");
            txtPurchasePrice.Text = clsProductGroupDetails.PurchasePrice.ToString("#,##0.#0");
            chkIncludeInSubtotalDiscount.Checked = clsProductGroupDetails.IncludeInSubtotalDiscount;
            txtVAT.Text      = clsProductGroupDetails.VAT.ToString("#,##0.#0");
            txtEVAT.Text     = clsProductGroupDetails.EVAT.ToString("#,##0.#0");
            txtLocalTax.Text = clsProductGroupDetails.LocalTax.ToString("#,##0.#0");
        }
Exemplo n.º 4
0
        protected void cboProductGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            Int64           intProductGroupID  = Convert.ToInt64(cboProductGroup.SelectedItem.Value);
            ProductSubGroup clsProductSubGroup = new ProductSubGroup();

            clsProductSubGroup.GetConnection();
            ProductGroup        clsProductGroup = new ProductGroup(clsProductSubGroup.Connection, clsProductSubGroup.Transaction);
            ProductGroupDetails clsDetails;

            //System.Data.DataTable dtProductSubGroup;

            if (intProductGroupID == 0)
            {
                clsDetails = clsProductGroup.Details(DataConstants.DEFAULT_PRODUCT_GROUP);
            }
            else
            {
                clsDetails = clsProductGroup.Details(intProductGroupID);
            }

            ProductSubGroupDetails clsSearchKeys = new ProductSubGroupDetails()
            {
                ProductGroupID = intProductGroupID
            };
            ProductSubGroupColumns clsProductSubGroupColumns = new ProductSubGroupColumns()
            {
                ColumnsNameID = true
            };

            ProductSubGroup clsSubGroup = new ProductSubGroup(clsProductGroup.Connection, clsProductGroup.Transaction);

            cboProductSubGroup.DataTextField  = "ProductSubGroupName";
            cboProductSubGroup.DataValueField = "ProductSubGroupID";
            cboProductSubGroup.DataSource     = clsSubGroup.ListAsDataTable(clsProductSubGroupColumns, clsSearchKeys, SortField: "ProductSubGroupName", SortOrder: System.Data.SqlClient.SortOrder.Ascending);
            cboProductSubGroup.DataBind();
            cboProductSubGroup.Items.Insert(0, new ListItem("Do not Apply to Product Sub Groups", "-1"));
            cboProductSubGroup.Items.Insert(1, new ListItem("Apply to all Product Sub Groups", "0"));
            cboProductSubGroup.SelectedIndex = cboProductSubGroup.Items.Count - 1;

            clsProductSubGroup.CommitAndDispose();

            cboChartOfAccountPurchase.SelectedIndex      = cboChartOfAccountPurchase.Items.IndexOf(cboChartOfAccountPurchase.Items.FindByValue(clsDetails.ChartOfAccountIDPurchase.ToString()));
            cboChartOfAccountSold.SelectedIndex          = cboChartOfAccountSold.Items.IndexOf(cboChartOfAccountSold.Items.FindByValue(clsDetails.ChartOfAccountIDSold.ToString()));
            cboChartOfAccountInventory.SelectedIndex     = cboChartOfAccountInventory.Items.IndexOf(cboChartOfAccountInventory.Items.FindByValue(clsDetails.ChartOfAccountIDInventory.ToString()));
            cboChartOfAccountIDTaxPurchase.SelectedIndex = cboChartOfAccountIDTaxPurchase.Items.IndexOf(cboChartOfAccountIDTaxPurchase.Items.FindByValue(clsDetails.ChartOfAccountIDTaxPurchase.ToString()));
            cboChartOfAccountIDTaxSold.SelectedIndex     = cboChartOfAccountIDTaxSold.Items.IndexOf(cboChartOfAccountIDTaxSold.Items.FindByValue(clsDetails.ChartOfAccountIDTaxSold.ToString()));
        }
Exemplo n.º 5
0
 protected void cboGroup_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (cboGroup.Items.Count != 0)
     {
         ProductGroup clsProductGroup = new ProductGroup();
         Int32        BaseUnitID      = clsProductGroup.Details(Convert.ToInt32(cboGroup.SelectedItem.Value)).UnitDetails.UnitID;
         cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.IndexOf(cboProductSubGroupUnit.Items.FindByValue(BaseUnitID.ToString()));
         clsProductGroup.CommitAndDispose();
     }
 }
Exemplo n.º 6
0
 protected void cboGroup_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (cboGroup.Items.Count != 0)
     {
         ProductGroup        clsProductGroup        = new ProductGroup();
         ProductGroupDetails clsProductGroupDetails = clsProductGroup.Details(Convert.ToInt32(cboGroup.SelectedItem.Value));
         cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.IndexOf(cboProductSubGroupUnit.Items.FindByValue(clsProductGroupDetails.UnitDetails.UnitID.ToString()));
         txtProductPrice.Text  = clsProductGroupDetails.Price.ToString("#,##0.#0");
         txtPurchasePrice.Text = clsProductGroupDetails.PurchasePrice.ToString("#,##0.#0");
         chkIncludeInSubtotalDiscount.Checked = clsProductGroupDetails.IncludeInSubtotalDiscount;
         txtVAT.Text      = clsProductGroupDetails.VAT.ToString("#,##0.#0");
         txtEVAT.Text     = clsProductGroupDetails.EVAT.ToString("#,##0.#0");
         txtLocalTax.Text = clsProductGroupDetails.LocalTax.ToString("#,##0.#0");
         clsProductGroup.CommitAndDispose();
     }
 }
Exemplo n.º 7
0
        private void LoadRecord()
        {
            Int64               iID             = Convert.ToInt64(Common.Decrypt(Request.QueryString["id"], Session.SessionID));
            ProductGroup        clsProductGroup = new ProductGroup();
            ProductGroupDetails clsDetails      = clsProductGroup.Details(iID);

            clsProductGroup.CommitAndDispose();

            lblProductGroupID.Text            = clsDetails.ProductGroupID.ToString();
            txtProductGroupCode.Text          = clsDetails.ProductGroupCode;
            txtProductGroupName.Text          = clsDetails.ProductGroupName;
            cboProductGroupUnit.SelectedIndex = cboProductGroupUnit.Items.IndexOf(cboProductGroupUnit.Items.FindByText(clsDetails.UnitDetails.UnitName));
            txtProductPrice.Text  = clsDetails.Price.ToString("#,##0.#0");
            txtPurchasePrice.Text = clsDetails.PurchasePrice.ToString("#,##0.#0");
            chkIncludeInSubtotalDiscount.Checked = clsDetails.IncludeInSubtotalDiscount;
            txtVAT.Text      = clsDetails.VAT.ToString("#,##0.#0");
            txtEVAT.Text     = clsDetails.EVAT.ToString("#,##0.#0");
            txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.#0");
        }
Exemplo n.º 8
0
 protected void cboProductGroup_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     try
     {
         LoadSubGroup();
         if (cboProductGroup.SelectedItem.Value != Constants.ZERO_STRING)
         {
             ProductGroup        clsProductGroup        = new ProductGroup();
             ProductGroupDetails clsProductGroupDetails = clsProductGroup.Details(long.Parse(cboProductGroup.SelectedItem.Value));
             clsProductGroup.CommitAndDispose();
             txtVAT.Text      = clsProductGroupDetails.VAT.ToString("#,##0.#0");
             txtEVAT.Text     = clsProductGroupDetails.EVAT.ToString("#,##0.#0");
             txtLocalTax.Text = clsProductGroupDetails.LocalTax.ToString("#,##0.#0");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
        private void LoadOptions()
        {
            DataClass clsDataClass = new DataClass();
            Int64     groupid      = Convert.ToInt64(Common.Decrypt(Request.QueryString["groupid"].ToString(), Session.SessionID));

            lblGroupID.Text = Convert.ToString(groupid);

            ProductGroupUnitsMatrix        clsUnitMatrix  = new ProductGroupUnitsMatrix();
            ProductGroupUnitsMatrixDetails clsUnitDetails = clsUnitMatrix.LastDetails(groupid);

            if (clsUnitDetails.BottomUnitName == null)
            {
                ProductGroup        clsProductGroup = new ProductGroup();
                ProductGroupDetails clsDetails      = clsProductGroup.Details(groupid);
                clsProductGroup.CommitAndDispose();

                txtBaseUnit.Text   = clsDetails.UnitDetails.UnitName;
                lblBaseUnitID.Text = clsDetails.UnitDetails.UnitID.ToString();
            }
            else
            {
                txtBaseUnit.Text   = clsUnitDetails.BottomUnitName;
                lblBaseUnitID.Text = Convert.ToString(clsUnitDetails.BottomUnitID);
            }

            cboBottomUnit.DataTextField  = "UnitName";
            cboBottomUnit.DataValueField = "UnitID";
            cboBottomUnit.DataSource     = clsDataClass.DataReaderToDataTable(clsUnitMatrix.AvailableUnitsForProduct(groupid, "UnitName", SortOption.Ascending)).DefaultView;
            cboBottomUnit.DataBind();
            if (cboBottomUnit.Items.Contains(new ListItem(txtBaseUnit.Text, lblBaseUnitID.Text)))
            {
                cboBottomUnit.Items.RemoveAt(cboBottomUnit.Items.IndexOf(cboBottomUnit.Items.FindByValue(lblBaseUnitID.Text)));
            }
            cboBottomUnit.SelectedIndex = cboBottomUnit.Items.Count - 1;

            clsUnitMatrix.CommitAndDispose();
        }
Exemplo n.º 10
0
        private void LoadOptions()
        {
            ProductGroup clsProductGroup = new ProductGroup();
            DataClass    clsDataClass    = new DataClass();

            cboGroup.DataTextField  = "ProductGroupName";
            cboGroup.DataValueField = "ProductGroupID";
            cboGroup.DataSource     = clsProductGroup.ListAsDataTable(SortField: "ProductGroupName").DefaultView;
            cboGroup.DataBind();
            cboGroup.SelectedIndex = cboGroup.Items.Count - 1;
            cboGroup_SelectedIndexChanged(null, System.EventArgs.Empty);

            Data.Unit clsUnit = new Data.Unit();

            cboProductSubGroupUnit.DataTextField  = "UnitName";
            cboProductSubGroupUnit.DataValueField = "UnitID";
            cboProductSubGroupUnit.DataSource     = clsUnit.ListAsDataTable(SortField: "UnitName").DefaultView;
            cboProductSubGroupUnit.DataBind();
            cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.Count - 1;

            Terminal        clsTerminal        = new Terminal(clsUnit.Connection, clsUnit.Transaction);
            TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString());

            txtVAT.Text      = clsTerminalDetails.VAT.ToString("###.#0");
            txtEVAT.Text     = clsTerminalDetails.EVAT.ToString("###.#0");
            txtLocalTax.Text = clsTerminalDetails.LocalTax.ToString("###.#0");

            clsUnit.CommitAndDispose();

            if (cboGroup.Items.Count != 0)
            {
                Int32 BaseUnitID = clsProductGroup.Details(Convert.ToInt32(cboGroup.SelectedItem.Value)).UnitDetails.UnitID;
                cboProductSubGroupUnit.SelectedIndex = cboProductSubGroupUnit.Items.IndexOf(cboProductSubGroupUnit.Items.FindByValue(BaseUnitID.ToString()));
            }
            clsProductGroup.CommitAndDispose();
        }
Exemplo n.º 11
0
        private void LoadList()
        {
            string SortField = "ProductCode";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            Int64 lngProductGroupID = Convert.ToInt64(cboProductGroup.SelectedItem.Value);

            ProductInventories clsProductInventories = new ProductInventories();

            System.Data.DataTable dt = clsProductInventories.ListAsDataTable(BranchID: int.Parse(cboBranch.SelectedItem.Value), ProductGroupID: lngProductGroupID, clsProductListFilterType: ProductListFilterType.ShowActiveOnly, SortField: "ProductDesc ASC, MatrixDescription ASC, BarCode1", SortOrder: SortOption.Desscending);

            ProductGroup        clsProductGroup        = new ProductGroup(clsProductInventories.Connection, clsProductInventories.Transaction);
            ProductGroupDetails clsProductGroupDetails = clsProductGroup.Details(lngProductGroupID);

            clsProductInventories.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

            if (!clsProductGroupDetails.isLock)
            {
                cmdLockUnlockProduct.Text    = "Lock Product Group [<label class='ms-error'>Note:</label>Products under this group are <u>CURRENTLY ALLOWED</u> for Selling]";
                cmdLockUnlockProduct.ToolTip = "unlock";
            }
            else
            {
                cmdLockUnlockProduct.Text    = "UnLock Product Group [<label class='ms-error'>Note:</label>Products under this group are <u>CURRENTLY NOT ALLOWED</u> for Selling]";
                cmdLockUnlockProduct.ToolTip = "lock";
            }

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = 5000;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int iRow = 0; iRow < PageData.PageCount; iRow++)
            {
                int iValue = iRow + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == iRow)
                {
                    cboCurrentPage.Items[iRow].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[iRow].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Exemplo n.º 12
0
        private void Upload()
        {
            if ((txtPath.PostedFile != null) && (txtPath.PostedFile.ContentLength > 0))
            {
                string fn           = System.IO.Path.GetFileName(txtPath.PostedFile.FileName);
                string SaveLocation = "/RetailPlus/temp/uploaded_" + fn;

                txtPath.PostedFile.SaveAs(SaveLocation);
                XmlTextReader reader = new XmlTextReader(SaveLocation);
                reader.WhitespaceHandling = WhitespaceHandling.None;

                Stock clsStock = new Stock();
                clsStock.GetConnection();

                string strStockTransactionNo = null;
                long   StockID             = 0;
                long   ContactID           = 0;
                int    UnitID              = 0;
                long   ProductGroupID      = 0;
                long   ProductSubGroupID   = 0;
                long   ProductID           = 0;
                long   ProductBaseMatrixID = 0;

                VariationDetails clsVariationDetails;
                int VariationID = 0;

                StockItemDetails clsStockItemDetails = new StockItemDetails();

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name == "Stock")
                        {
                            strStockTransactionNo = reader.GetAttribute("TransactionNo");

                            StockID = clsStock.Details(reader.GetAttribute("TransactionNo")).StockID;
                            if (StockID > 0)
                            {
                                clsStock.CommitAndDispose();
                                Label1.Text  = "<b>This file has already been added to inventory.<br />";
                                Label1.Text += "Please refer to transaction No: " + strStockTransactionNo + ".</b>";
                                reader.Close();
                                return;
                            }
                            Contacts clsContact = new Contacts(clsStock.Connection, clsStock.Transaction);
                            ContactID = clsContact.Details(reader.GetAttribute("ContactCode")).ContactID;
                            if (ContactID == 0)
                            {
                                ContactDetails clsContactDetails = new ContactDetails();
                                clsContactDetails.ContactCode     = reader.GetAttribute("ContactCode");
                                clsContactDetails.ContactName     = reader.GetAttribute("ContactName");
                                clsContactDetails.ContactGroupID  = Convert.ToInt32(reader.GetAttribute("ContactGroupID"));
                                clsContactDetails.ModeOfTerms     = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), reader.GetAttribute("ModeOfTerms"));
                                clsContactDetails.Terms           = Convert.ToInt32(reader.GetAttribute("Terms"));
                                clsContactDetails.Address         = reader.GetAttribute("Address");
                                clsContactDetails.BusinessName    = reader.GetAttribute("BusinessName");
                                clsContactDetails.TelephoneNo     = reader.GetAttribute("TelephoneNo");
                                clsContactDetails.Remarks         = reader.GetAttribute("Remarks");
                                clsContactDetails.Debit           = Convert.ToDecimal(reader.GetAttribute("Debit"));
                                clsContactDetails.Credit          = Convert.ToDecimal(reader.GetAttribute("Credit"));
                                clsContactDetails.IsCreditAllowed = Convert.ToBoolean(reader.GetAttribute("IsCreditAllowed"));
                                clsContactDetails.CreditLimit     = Convert.ToDecimal(reader.GetAttribute("CreditLimit"));
                                ContactID = clsContact.Insert(clsContactDetails);
                            }

                            StockDetails clsStockDetails = new StockDetails();
                            clsStockDetails.TransactionNo = reader.GetAttribute("TransactionNo");
                            clsStockDetails.StockTypeID   = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID);
                            clsStockDetails.StockDate     = DateTime.Now;
                            clsStockDetails.SupplierID    = ContactID;
                            clsStockDetails.Remarks       = reader.GetAttribute("StockRemarks") + Environment.NewLine + "Original Stock Date: " + reader.GetAttribute("StockDate");

                            StockItemDetails[] itemDetails = new StockItemDetails[0];
                            clsStockDetails.StockItems = itemDetails;

                            StockID = clsStock.Insert(clsStockDetails);
                        }
                        else if (reader.Name == "Item")
                        {
                            Data.Unit clsUnit = new Data.Unit(clsStock.Connection, clsStock.Transaction);
                            UnitID = clsUnit.Details(reader.GetAttribute("ProductUnitCode")).UnitID;
                            if (UnitID == 0)
                            {
                                UnitDetails clsUnitDetails = new UnitDetails();
                                clsUnitDetails.UnitCode = reader.GetAttribute("ProductUnitCode");
                                clsUnitDetails.UnitName = reader.GetAttribute("ProductUnitName");
                                UnitID = clsUnit.Insert(clsUnitDetails);
                            }

                            ProductGroup clsProductGroup = new ProductGroup(clsStock.Connection, clsStock.Transaction);
                            ProductGroupID = clsProductGroup.Details(reader.GetAttribute("ProductGroupCode")).ProductGroupID;
                            if (ProductGroupID == 0)
                            {
                                Label1.Text += "inserting product group....";
                                ProductGroupDetails clsProductGroupDetails = new ProductGroupDetails();
                                clsProductGroupDetails.ProductGroupCode = reader.GetAttribute("ProductGroupCode");
                                clsProductGroupDetails.ProductGroupName = reader.GetAttribute("ProductGroupName");
                                clsProductGroupDetails.UnitDetails      = new UnitDetails
                                {
                                    UnitID = UnitID
                                };
                                clsProductGroupDetails.Price                     = Convert.ToDecimal(reader.GetAttribute("Price"));
                                clsProductGroupDetails.PurchasePrice             = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
                                clsProductGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
                                clsProductGroupDetails.VAT      = Convert.ToDecimal(reader.GetAttribute("VAT"));
                                clsProductGroupDetails.EVAT     = Convert.ToDecimal(reader.GetAttribute("EVAT"));
                                clsProductGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
                                ProductGroupID = clsProductGroup.Insert(clsProductGroupDetails);
                            }

                            ProductSubGroup clsProductSubGroup = new ProductSubGroup(clsStock.Connection, clsStock.Transaction);
                            ProductSubGroupID = clsProductSubGroup.Details(reader.GetAttribute("ProductSubGroupCode")).ProductSubGroupID;
                            if (ProductSubGroupID == 0)
                            {
                                Label1.Text += "inserting product sub-group....";
                                ProductSubGroupDetails clsProductSubGroupDetails = new ProductSubGroupDetails();
                                clsProductSubGroupDetails.ProductGroupID      = ProductGroupID;
                                clsProductSubGroupDetails.ProductSubGroupCode = reader.GetAttribute("ProductSubGroupCode");
                                clsProductSubGroupDetails.ProductSubGroupName = reader.GetAttribute("ProductSubGroupName");
                                clsProductSubGroupDetails.BaseUnitID          = UnitID;
                                clsProductSubGroupDetails.Price                     = Convert.ToDecimal(reader.GetAttribute("Price"));
                                clsProductSubGroupDetails.PurchasePrice             = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
                                clsProductSubGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
                                clsProductSubGroupDetails.VAT      = Convert.ToDecimal(reader.GetAttribute("VAT"));
                                clsProductSubGroupDetails.EVAT     = Convert.ToDecimal(reader.GetAttribute("EVAT"));
                                clsProductSubGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
                                ProductSubGroupID = clsProductSubGroup.Insert(clsProductSubGroupDetails);
                            }

                            Products clsProduct = new Products(clsStock.Connection, clsStock.Transaction);
                            ProductID = clsProduct.Details(reader.GetAttribute("BarCode")).ProductID;
                            if (ProductID == 0)
                            {
                                Label1.Text += "inserting product....";
                                ProductDetails clsProductDetails = new ProductDetails();
                                clsProductDetails.ProductCode               = reader.GetAttribute("ProductCode");
                                clsProductDetails.BarCode                   = reader.GetAttribute("BarCode");
                                clsProductDetails.ProductDesc               = reader.GetAttribute("ProductDesc");
                                clsProductDetails.ProductGroupID            = ProductGroupID;
                                clsProductDetails.ProductSubGroupID         = ProductSubGroupID;
                                clsProductDetails.ProductDesc               = reader.GetAttribute("ProductDesc");
                                clsProductDetails.BaseUnitID                = UnitID;
                                clsProductDetails.Price                     = Convert.ToDecimal(reader.GetAttribute("Price"));
                                clsProductDetails.PurchasePrice             = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
                                clsProductDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
                                clsProductDetails.VAT          = Convert.ToDecimal(reader.GetAttribute("VAT"));
                                clsProductDetails.EVAT         = Convert.ToDecimal(reader.GetAttribute("EVAT"));
                                clsProductDetails.LocalTax     = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
                                clsProductDetails.Quantity     = 0;
                                clsProductDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold"));
                                clsProductDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold"));
                                clsProductDetails.SupplierID   = Contacts.DEFAULT_SUPPLIER_ID;
                                ProductID = clsProduct.Insert(clsProductDetails);
                            }

                            //ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction);
                            //ProductBaseMatrixID = clsProductVariationsMatrix.BaseDetails(0, 0, ProductID, reader["ItemBaseVariationDescription"].ToString()).MatrixID;
                            //if (ProductBaseMatrixID == 0)
                            //{
                            //    ProductBaseMatrixDetails clsBaseDetails = new ProductBaseMatrixDetails();
                            //    clsBaseDetails.ProductID = ProductID;
                            //    clsBaseDetails.Description = reader.GetAttribute("ItemBaseVariationDescription");
                            //    clsBaseDetails.UnitID = UnitID;
                            //    clsBaseDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price"));
                            //    clsBaseDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
                            //    clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
                            //    clsBaseDetails.Quantity = 0;
                            //    clsBaseDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT"));
                            //    clsBaseDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT"));
                            //    clsBaseDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
                            //    clsBaseDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold"));
                            //    clsBaseDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold"));
                            //    ProductBaseMatrixID = clsProductVariationsMatrix.InsertBaseVariation(clsBaseDetails);
                            //    clsBaseDetails.MatrixID = ProductBaseMatrixID;
                            //}

                            clsStockItemDetails                   = new StockItemDetails();
                            clsStockItemDetails.StockID           = StockID;
                            clsStockItemDetails.ProductID         = ProductID;
                            clsStockItemDetails.VariationMatrixID = ProductBaseMatrixID;
                            clsStockItemDetails.ProductUnitID     = UnitID;
                            clsStockItemDetails.StockTypeID       = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID);
                            clsStockItemDetails.StockDate         = DateTime.Now;
                            clsStockItemDetails.Quantity          = Convert.ToDecimal(reader.GetAttribute("ItemQuantity"));
                            clsStockItemDetails.Remarks           = reader.GetAttribute("ItemRemarks");

                            Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
                            clsStock.AddItem(Constants.BRANCH_ID_MAIN, strStockTransactionNo, clsAccessUserDetails.Name, clsStockItemDetails, StockDirections.Increment);
                        }
                        else if (reader.Name == "Variation" && reader.GetAttribute("VariationCode") != null)
                        {
                            Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction);
                            VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID;
                            if (VariationID == 0)
                            {
                                clsVariationDetails = new VariationDetails();
                                clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode");
                                clsVariationDetails.VariationType = reader.GetAttribute("VariationType");
                                VariationID = clsVariation.Insert(clsVariationDetails);
                            }

                            ProductVariationDetails clsProductVariationDetails = new ProductVariationDetails();
                            clsProductVariationDetails.ProductID   = ProductID;
                            clsProductVariationDetails.VariationID = VariationID;

                            ProductVariations clsProductVariation = new ProductVariations(clsStock.Connection, clsStock.Transaction);
                            if (clsProductVariation.isExist(clsProductVariationDetails) == false)
                            {
                                long ProductVariationID = clsProductVariation.Insert(clsProductVariationDetails);
                            }
                        }
                        else if (reader.Name == "VariationMatrix" && reader.GetAttribute("VariationCode") != null)
                        {
                            Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction);
                            VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID;
                            if (VariationID == 0)
                            {
                                clsVariationDetails = new VariationDetails();
                                clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode");
                                clsVariationDetails.VariationType = reader.GetAttribute("VariationType");
                                VariationID = clsVariation.Insert(clsVariationDetails);
                            }

                            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction);
                            if (clsProductVariationsMatrix.isExist(ProductBaseMatrixID, VariationID) == false)
                            {
                                ProductVariationsMatrixDetails clsProductVariationsMatrixDetails = new ProductVariationsMatrixDetails();
                                clsProductVariationsMatrixDetails.ProductID   = ProductID;
                                clsProductVariationsMatrixDetails.MatrixID    = ProductBaseMatrixID;
                                clsProductVariationsMatrixDetails.VariationID = VariationID;
                                clsProductVariationsMatrixDetails.Description = reader.GetAttribute("Description");
                                clsProductVariationsMatrix.SaveVariation(clsProductVariationsMatrixDetails);
                            }
                        }
                        else
                        {
                            Label1.Text = "<b>Reader Name:<b>" + reader.Name + "<br />";
                        }
                        break;

                    case XmlNodeType.Text:
                        Label1.Text = "<b>" + reader.LocalName + ":<b>" + reader.Value + "<br />";
                        break;
                    }
                }
                reader.Close();

                clsStock.CommitAndDispose();
                Label1.Text = "<b>Transaction No.: " + strStockTransactionNo + " has been successfully transferred.<br />";
            }
            else
            {
                Response.Write("Please select a file to upload.");
            }
        }