protected void btnSave_Click(object sender, EventArgs e)
        {
            GetObjectsFromDropList();
            GetCommissionRatesGrid();
            GetPayablesValue();

            OutletClass NewOutlet = new OutletClass();

            if (btnSave.Text == "UPDATE")
            {
                GetUpdateInfo();
            }
            else
            {
                    OM.CollectionAddress = txtCollectionAddress.Text;
                    OM.DepartmentCode = txtDepartmentCode.Text;
                    //CustomerNo
                    NewOutlet.CompanyName = OM.OutletName;
                    //MainCustomerNo    //MainCustomerNo = null,
                    //CustomerCode
                    //CustomerType
                    NewOutlet.BrandName = dlBrand.Text;
                    //CBrand
                    NewOutlet.AgentName = txtAreaCoordinator.Text;
                    NewOutlet.PriceGroupNo = Convert.ToInt32(dlPriceGroupReg.SelectedValue);
                    NewOutlet.PriceGroupMarkdownNo = Convert.ToInt32(dlPriceGroupMDown.SelectedValue);
                    NewOutlet.AreaGroupNo = Convert.ToInt32(dlAreaGroup.SelectedValue);
                    NewOutlet.SubAreaGroupNo = Convert.ToInt32(dlSubAreaGroup.SelectedValue);
                    //BrandNameNo
                    //BrandNameNo2
                    NewOutlet.CompanyNo = Convert.ToInt32(dlUnderCompany.SelectedValue);
                    //ArrangementType
                    //AddressOne
                    //AddressTwo
                    //TIN_No
                    //ContactPerson
                    //DesignationPost
                    //TelephoneNo
                    //CellphoneNo
                    //FaxNo
                    NewOutlet.BillingAddress = txtCollectionAddress.Text;
                    //ShippingAddress
                    //OrderedList
                    NewOutlet.CreditLimit = (float)Convert.ToDecimal(txtCreditLimit.Text);
                    NewOutlet.Terms = txtTerms.Text;
                    NewOutlet.ContractDate = Convert.ToDateTime(txtDateStart.Text);
                    NewOutlet.LiquidationStatus = Convert.ToInt16(rdioLiquidationStatus.SelectedValue);

            }
            //SAVE FIRST TO CUSTOMER REFERENCE TABLE
            try
            {
                if (btnSave.Text.ToUpper() == "SAVE")
                    OM.Save(NewOutlet);
                else
                    OM.Update();

                OM.SaveContract(this.commRateListAccessor, this.customerPayableListAccessor);
                ResponseMessage("Saved new outlet (Outlet Code:" + OM.OutletCode + ")");
                ResetContents();

                //btnClear.Click();
            }
            catch (Exception except)
            {
                throw new System.ArgumentException(except.Message);
            }
            Response.Redirect("CustomListing.aspx");
        }
        public bool FindOutlet(string outletCode)
        {
            bool bResult = false;
            try
            {
                outlet = OutletAccessor.GetOutletByOutletCode(outletCode);
                outletRefLink = OutletLinkAccessor.OutletReference(outletCode);
                if (outlet != null)
                {
                    bResult = true;
                }
            }
            catch (Exception except)
            {
            }

            return bResult;
        }
        public void Save(OutletClass _outlet)
        {
            using (DbManager db = new DbManager())
            {
                try
                {
                    _outlet.AddressOne = branch.AddressOne;
                    _outlet.AddressTwo = branch.AddressTwo;
                    _outlet.ArrangementType = "CONCESSION";
                    _outlet.ContactPerson = branch.ContactPerson;
                    _outlet.DesignationPost = branch.PositionDescription;
                    _outlet.ShippingAddress = branch.ShippingAddress;
                    _outlet.TelephoneNo = branch.TelephoneNumber;
                    _outlet.FaxNo = branch.FaxNumber;
                    _outlet.TIN_No = branch.TIN;

                    if (!string.IsNullOrEmpty(_outlet.CustomerCode))
                    {
                        SaveOutletReferenceLink(_outlet.CustomerCode, false);
                        OutletAccessor.Query.Update(db, _outlet);
                    }
                    else
                    {
                        //this.outletRefLink.CustomerCode = GenerateOutletCode();
                        SaveOutletReferenceLink(GenerateOutletCode(), true);
                        _outlet.CustomerCode = outletRefLink.CustomerCode;
                        OutletAccessor.Query.Insert(db, _outlet);
                    }
                }
                catch (Exception except)
                {
                    throw new System.ArgumentException(except.Message);
                }
            }
        }
 public void Delete(OutletClass outlet)
 {
     using (DbManager db = new DbManager())
     {
         OutletAccessor.Query.Delete(db, outlet);
     }
 }