public void DeleteCustomerForwarder(ForwarderCustomer ForwarderCustomer)
 {
     using (DbManager db = new DbManager())
     {
         Accessor.Query.Delete(db, ForwarderCustomer);
     }
 }
 protected void btnChangeSave_Click(object sender, EventArgs e)
 {
     Image imgRecordNumber = (Image)gvCustomers.SelectedRow.FindControl("imgCustomer");
     ForwarderCustomer FC = new ForwarderCustomer();
     FC = FM.GetForwarderCustomerByID(long.Parse(imgRecordNumber.AlternateText));
     FC.ForwarderNumber = long.Parse(dlForwarders.SelectedValue);
     FM.SaveForwarderCustomer(FC);
     gvCustomers.DataBind();
     btnViewCustomers_ModalPopupExtender.Show();
 }
        protected void btnContinueSave_Click(object sender, EventArgs e)
        {
            List<ForwarderCustomer> ForwarderCustomers = new List<ForwarderCustomer>();
            long forwarder = long.Parse(hfForwarderRecordNumber.Value);

            foreach (GridViewRow row in gvSelectedCustomers.Rows)
            {
                CheckBox chk = (CheckBox)row.FindControl("chkSelectedCustomer");
                if (chk.Checked == true)
                {
                    ForwarderCustomer fc = new ForwarderCustomer();
                    fc.ForwarderNumber = forwarder;
                    fc.CustomerNumber = long.Parse(chk.ToolTip);
                    ForwarderCustomers.Add(fc);
                }
            }
            FM.SaveForwarderCustomers(ForwarderCustomers);
            Redirector.Redirect("~/WareHouse/ForwarderManagementPanel.aspx");
        }
 public void SaveForwarderCustomer(ForwarderCustomer ForwarderCustomer)
 {
     using (DbManager db = new DbManager())
     {
         if (ForwarderCustomer.RecordNumber > 0)
         {
             Accessor.Query.Update(db, ForwarderCustomer);
         }
         else
         {
             Accessor.Query.Insert(db, ForwarderCustomer);
         }
     }
 }
        protected void btnSetAsDefaultForwarder_Click(object sender, EventArgs e)
        {
            long  recordNumber = long.Parse(gvOtherForwarder.SelectedDataKey.Values[0].ToString());
            long customerNumber = long.Parse(gvOtherForwarder.SelectedDataKey.Values[2].ToString());
            long forwarderNumber = long.Parse(hfRecordNo.Value);
            bool isDefault = bool.Parse(gvOtherForwarder.SelectedDataKey.Values[1].ToString());
            ForwarderCustomer defaultForwarder= FM.GetDefaultForwarder(customerNumber);

            if (defaultForwarder!=null)
            {
                defaultForwarder.IsDefault = false;
                FM.SaveForwarderCustomer(defaultForwarder);
                ForwarderCustomer forwarderCustomer = new ForwarderCustomer
                {
                    RecordNumber = recordNumber,
                    IsDefault = true,
                    CustomerNumber = customerNumber,
                    ForwarderNumber = long.Parse(gvOtherForwarder.SelectedDataKey.Values[3].ToString())
                };
                FM.SaveForwarderCustomer(forwarderCustomer);
            }
            else
            {
                ForwarderCustomer forwarderCustomer = new ForwarderCustomer
                {
                    RecordNumber = recordNumber,
                    IsDefault = true,
                    CustomerNumber = customerNumber,
                    ForwarderNumber = forwarderNumber
                };
                FM.SaveForwarderCustomer(forwarderCustomer);
            }

            gvOtherForwarder.DataBind();
            btnSetAsDefaultForwarder.Visible = false;
            btnOtherForwarder_ModalPopupExtender.Show();
            btnViewCustomers_ModalPopupExtender.Show();
        }