private void LockUnlockForSelling(string UnLock = "")
        {
            bool isLock = false;

            if (UnLock == "Unlock")
            {
                isLock = false;
            }
            else if (cmdLockUnlockProduct.ToolTip == "unlock")
            {
                isLock = true;
            }

            Products clsProducts = new Products();
            clsProducts.LockUnlockForSellingBySupplier(int.Parse(cboBranch.SelectedItem.Value), long.Parse(cboContact.SelectedItem.Value), isLock);
            clsProducts.CommitAndDispose();

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

            try
            {
                DateTime DeliveryDate = Convert.ToDateTime(txtClosingDate.Text);

                ERPConfig clsERPConfig = new ERPConfig();
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
                {
                    string strReferenceNo = Constants.CLOSE_INVENTORY_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsERPConfig.get_LastClosingNo();

                    AccessUserDetails clsAccessUserDetails = (AccessUserDetails)Session["AccessUserDetails"];

                    ProductInventories clsProductInventories = new ProductInventories(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProductInventories.CloseInventoryBySupplier(int.Parse(cboBranch.SelectedItem.Value), clsAccessUserDetails.UID, DateTime.Parse(txtClosingDate.Text), strReferenceNo, long.Parse(cboContact.SelectedItem.Value), cboContact.SelectedItem.Text);

                    Products clsProducts = new Products(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProducts.LockUnlockForSellingBySupplier(int.Parse(cboBranch.SelectedItem.Value), long.Parse(cboContact.SelectedItem.Value), false);

                    clsERPConfig.CommitAndDispose();
                    strRetValue = strReferenceNo;
                }
                else
                {
                    clsERPConfig.CommitAndDispose();
                    string stScript = "<Script>";
                    stScript += "window.alert('Sorry you cannot close using the closing date: " + txtClosingDate.Text + ". Please enter an allowable posting date.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                }
            }
            catch (Exception ex)
            {
                string stScript = "<Script>";
                stScript += "window.alert('An error has occured while closing the inventory. Details:' " + ex.Message + ")";
                stScript += "</Script>";
                Response.Write(stScript);
            }
            return strRetValue;
        }