Example #1
0
        public bool Remove(CustomerObject customer)
        {
            SqlCommand cmd = null;

            try
            {
                ExecuteNonQuery(out cmd, false, "Customer_DELETE",
                                CreateParameter("@cusID", SqlDbType.UniqueIdentifier, customer.CusID, ParameterDirection.Input)
                                );
                return(true);
            }
            catch (Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                cmd = null;
            }
        }
        public async Task <IActionResult> PutCustomer(int id, CustomerObject customerObject)
        {
            if (id != customerObject.Id)
            {
                return(new ContentResult()
                {
                    Content = "You cannot change customer's id.",
                    StatusCode = StatusCodes.Status400BadRequest
                });
            }

            _context.Entry(customerObject).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(new ContentResult()
            {
                Content = "Customer has been updated.",
                StatusCode = StatusCodes.Status202Accepted
            });
        }
Example #3
0
 public void Remove(CustomerObject customer)
 {
     try
     {
         CheckTransaction();
         new CustomerDataService(Transaction).Remove(customer);
         if (IsOwner)
         {
             Transaction.Commit();
         }
     }
     catch (Exception exception1)
     {
         if (IsOwner)
         {
             Transaction.Rollback();
         }
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     finally
     {
         if (IsOwner)
         {
             Connection.Close();
         }
     }
 }
        private void EnabledRemoveButton()
        {
            List <RibbonButton> listRibbonButton = CustomerObject.GetLogicalChildCollection <RibbonButton>(this);

            foreach (RibbonButton rbtn in listRibbonButton)
            {
                if (rbtn.Name.Contains("btnContentRemove"))
                {
                    string[] tag = rbtn.Tag.ToString().SplitByDelimiter("#");

                    DsNhomCap itemNhomCap = lstNhomCap[Convert.ToInt32(tag[0].Replace("NhomCap", ""))];
                    if (Convert.ToInt32(tag[1]) == (itemNhomCap.LstCap.Count - 1))
                    {
                        rbtn.IsEnabled = true;
                    }
                    else
                    {
                        rbtn.IsEnabled = false;
                    }
                }
                else if (rbtn.Name.Contains("btnRemove"))
                {
                    if (Convert.ToInt32(rbtn.Tag.ToString()) == (lstNhomCap.Count - 1))
                    {
                        rbtn.IsEnabled = true;
                    }
                    else
                    {
                        rbtn.IsEnabled = false;
                    }
                }
            }
        }
        public CustomerObject GetInfoAddedCustomerObject(MySqlDataReader dr)
        {
            var returnOb = new CustomerObject();

            returnOb.Id           = Convert.ToInt32(dr["id"]);
            returnOb.name         = dr["name"] != null ? dr["name"].ToString() : "";
            returnOb.emailAddress = dr["email_address"].ToString();
            returnOb.telephoneNo  = dr["telephone_no"] != null ? dr["telephone_no"].ToString() : "";
            var add = dr["address"] != null ? dr["address"].ToString().Split('|') : null;

            if (add != null)
            {
                if (add.Count() > 2)
                {
                    returnOb.addressLine1 = add[0];
                    returnOb.addressLine2 = add[1];
                    returnOb.city         = add[2];
                }
            }

            returnOb.username       = dr["username"].ToString();
            returnOb.password       = dr["password"].ToString();
            returnOb.registeredDate = Convert.ToDateTime(dr["registered_date"]);
            returnOb.active         = Convert.ToBoolean(Convert.ToInt32(dr["active"].ToString()));

            return(returnOb);
        }
Example #6
0
    public List <CustomerObject> FetchCustomersByName(CustomerObject obj)
    {
        // don't create the DAL here...
        //Maybe other operations
        List <CustomerObject> list = customerDal.FetchByName(obj.Name);

        //Maybe other operations over list
        return(list);
    }
    public void GetNewCustomer(CustomerObject shopVisitor)
    {
        AudioController.instance.PlaySoundEffect(AudioController.instance.shopBell);
        customerObject = shopVisitor;
        customerObject.gameObject.SetActive(true);
        customerObject.FadeIn();

        DialogueController.instance.customerNameToDisplay = customerObject.customerName;
    }
    internal void CustomerLeft()
    {
        AudioController.instance.PlaySoundEffect(AudioController.instance.shopBell);

        customerObject = null;

        customerArrived = false;

        currentDialogueIteration = 0;
    }
Example #9
0
        //update loyalty card

        private void btn_loy_update_Click(object sender, EventArgs e)
        {
            if (CustomerLoyaltyCardValidation())
            {
                DialogResult dr;
                dr = MessageBox.Show("Do you want to update the record", "Confirm", MessageBoxButtons.YesNo);
                if (dr.ToString() == "Yes")
                {
                    CustomerObject objCustomer = new CustomerObject();

                    objCustomer.Nic      = txt_loy_nic.Text;
                    objCustomer.CardType = cmb_loy_cardtype.SelectedItem.ToString();
                    objCustomer.CardNo   = lbl_loymem_cardno.Text;
                    //  objCustomer.CardPoints = Convert.ToInt32(txtb_loy_cardpoints.Text);
                    objCustomer.CardPoints = 0;

                    try
                    {
                        MegaCoolMethods mcm    = new MegaCoolMethods();
                        bool            result = mcm.EditLoyaltyCard(objCustomer);

                        if (result)
                        {
                            MessageBox.Show("Successfully Updated", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            CustomerFillGrid();
                        }
                        else
                        {
                            MessageBox.Show("Unable to Update", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (ApplicationException appEx)
                    {
                        MessageBox.Show(appEx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Record is not updated", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            CustomerLotaltyCardFillGrid();
            Clear();
            btn_loy_add.Enabled = true;
        }
Example #10
0
        public TurnOverObjectCollection GetByCustomer(CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers;

            try
            {
                turnOvers = new TurnOverDataService().GetByCustomer(customer);
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(turnOvers);
        }
Example #11
0
 private void gdvCustomer_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         GridView       view        = (GridView)sender;
         CustomerObject customerObj = (CustomerObject)view.GetRow(view.FocusedRowHandle);
         Customer       customer    = new Customer(PROF_IT.Common.Enumerations.TypeForm.PropertyForm, customerObj);
         customer.ShowDialog();
     }
     catch (System.Exception excepion1)
     {
         System.Exception thisException = excepion1;
         Management.ShowException(thisException);
     }
 }
Example #12
0
        public Decimal GetAverageTurnOverMonthByYearByCustomer(int year, CustomerObject customer)
        {
            Decimal turnOver;

            try
            {
                turnOver = new TurnOverDataService().GetAverageTurnOverMonthByYearByCustomer(customer, year);
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(turnOver);
        }
        public async Task <ActionResult <CustomerObject> > GetCustomer(int id)
        {
            CustomerObject customerObject = await _context.TbCustomers.FindAsync(id);

            if (customerObject == null)
            {
                return(new ContentResult()
                {
                    Content = "Customer does not exist.",
                    StatusCode = StatusCodes.Status403Forbidden
                });
            }

            return(customerObject);
        }
Example #14
0
 public TurnOver(CustomerObject customer)
 {
     try
     {
         InitializeComponent();
         _blTurnover = new BL.External.TAS.TurnOver.TurnOver();
         _customer   = customer;
         FillControls();
         AddSerie(1, System.DateTime.Now.Year);
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Example #15
0
    private IEnumerator AttemptToSell(CustomerObject customerObject)
    {
        CustomerObject.DesireSettings.DesireResponse desireValue;
        if (m_DesireToBuy <= customerObject.desireSettings.min.value)
        {
            desireValue = customerObject.desireSettings.min.responses;
        }
        else if (m_DesireToBuy >= customerObject.desireSettings.max.value)
        {
            desireValue = customerObject.desireSettings.max.responses;
        }
        else
        {
            desireValue = customerObject.desireSettings.neutralResponses;
        }

        m_CharacterAnimator.CrossFade("Neutral", 0.2f);

        if (desireValue.salesPitch != string.Empty)
        {
            m_CharacterNameText.text = "You";
            m_TextBox.text           = desireValue.salesPitch;

            yield return(WaitForUser());
        }

        if (desireValue.characterResponse != string.Empty)
        {
            m_CharacterNameText.text = customerObject.name;

            m_TextBox.text = desireValue.characterResponse;
            m_CharacterAnimator.CrossFade(desireValue.mood, m_CrossfadeTime);

            yield return(WaitForUser());
        }

        if (desireValue.selfResponse != string.Empty)
        {
            m_CharacterNameText.text = "You";

            m_TextBox.text = desireValue.selfResponse;

            yield return(WaitForUser());
        }
    }
Example #16
0
    public static void ProcessCustomerData_XmlSerializerFormat_Soap()
    {
        RunWcfSoapServiceTest((serviceProxy) =>
        {
            // *** EXECUTE *** \\
            CustomerObject value = new CustomerObject()
            {
                Name = "MyName", Data = new AdditionalData()
                {
                    Field = "Foo"
                }
            };
            string response = serviceProxy.ProcessCustomerData(value);

            // *** VALIDATE *** \\
            Assert.Equal("MyNameFoo", response);
        });
    }
Example #17
0
        public TurnOverObjectCollection GetByCustomer(CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
            SqlCommand cmd = null;

            try
            {
                cmd             = new SqlCommand("TAS_TurnOver_ByCustomer");
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@TNR_ID", customer.TasID));
                turnOvers = TurnOverConvertor.DataTableToCollection(this.ExecuteNonQuery(cmd, false).Tables[0]);
            }
            catch (System.Exception exception1)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
            }
            return(turnOvers);
        }
Example #18
0
        public Decimal GetTurnOverByYearByCustomer(CustomerObject customer, int year)
        {
            Decimal turnOver = 0;

            try
            {
                if (customer != null)
                {
                    turnOver = new TurnOverDataService().GetTurnOverByYearByCustomer(customer, year);
                }
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(turnOver);
        }
        private string getObject()
        {
            // string strResource = "0-20(id1|ma1,id2|ma2,id3|ma3;idI|maI,idII|maII,idIII|maIII@DDU1^id1|ma1,id2|ma2,id3|ma3;idI|maI,idII|maII,idIII|maIII@DDU2)
            string                     result                  = "";
            List <TextBox>             listTextBox             = CustomerObject.GetLogicalChildCollection <TextBox>(this);
            List <AutoCompleteTextBox> listAutoCompleteTextBox = CustomerObject.GetLogicalChildCollection <AutoCompleteTextBox>(this);

            foreach (DsNhomCap nhomCap in lstNhomCap)
            {
                string group = "";
                int    soCap = listAutoCompleteTextBox.Where(t => t.Name.Contains("txtMaCap") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Count();
                List <AutoCompleteTextBox> subListTextBox = listAutoCompleteTextBox.Where(t => t.Tag.ToString().Equals(nhomCap.MaNhomCap)).ToList();
                for (int i = 0; i < soCap; i++)
                {
                    if (i > 0)
                    {
                        group += "^";
                    }
                    string strTMaCap        = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtMaCap" + nhomCap.MaNhomCap + "_" + i) && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text;
                    string strCapNhomCapNSD = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtCapNhomCapNSD" + nhomCap.MaNhomCap + "_" + i)).Text;
                    if (!strCapNhomCapNSD.IsNullOrEmptyOrSpace())
                    {
                        strCapNhomCapNSD = strCapNhomCapNSD.Trim().Replace(" ", "");
                        strCapNhomCapNSD = strCapNhomCapNSD.Substring(0, strCapNhomCapNSD.Length);
                    }
                    string strCapNhomCapNNSD = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtCapNhomCapNNSD" + nhomCap.MaNhomCap + "_" + i)).Text;
                    if (!strCapNhomCapNNSD.IsNullOrEmptyOrSpace())
                    {
                        strCapNhomCapNNSD = strCapNhomCapNNSD.Trim().Replace(" ", "");
                        strCapNhomCapNNSD = strCapNhomCapNNSD.Substring(0, strCapNhomCapNNSD.Length);
                    }
                    group += strCapNhomCapNSD + ";" + strCapNhomCapNNSD + "@" + strTMaCap;
                }
                string strTu  = listTextBox.FirstOrDefault(t => t.Name.Contains("txtTu") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text;
                string strDen = listTextBox.FirstOrDefault(t => t.Name.Contains("txtDen") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text;
                result += strTu + "-" + strDen + "(" + group + ")";
                result += "#";
            }
            if (!result.IsNullOrEmptyOrSpace())
            {
                result = result.Substring(0, result.Length - 1);
            }
            return(result);
        }
        public async Task <ActionResult <CustomerObject> > PostCustomer(CustomerObject customerObject)
        {
            if (CustomerExists(customerObject.Id))
            {
                return(new ContentResult()
                {
                    Content = "Customer with this ID already exists.",
                    StatusCode = StatusCodes.Status403Forbidden
                });
            }

            _context.TbCustomers.Add(customerObject);
            await _context.SaveChangesAsync();

            return(new ContentResult()
            {
                Content = "Customer has been created.",
                StatusCode = StatusCodes.Status201Created
            });
        }
Example #21
0
 public Customer(PROF_IT.Common.Enumerations.TypeForm typeForm, CustomerObject customer)
 {
     try
     {
         InitializeComponent();
         _customer = customer;
         _typeForm = typeForm;
         if (_typeForm == PROF_IT.Common.Enumerations.TypeForm.NewForm)
         {
             throw new NotImplementedException();
         }
         else
         {
             InitializePropertyForm();
         }
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
        public async Task <IActionResult> DeleteCustomer(int id)
        {
            CustomerObject customerObject = await _context.TbCustomers.FindAsync(id);

            if (customerObject == null)
            {
                return(new ContentResult()
                {
                    Content = "Customer does not exist.",
                    StatusCode = StatusCodes.Status404NotFound
                });
            }

            _context.TbCustomers.Remove(customerObject);
            await _context.SaveChangesAsync();

            return(new ContentResult()
            {
                Content = "Customer has been deleted.",
                StatusCode = StatusCodes.Status202Accepted
            });
        }
Example #23
0
 void IEditableObject.EndEdit()
 {
     try
     {
         if (inTxn)
         {
             _loadedTask     = this.Task;
             _loadedEmployee = this.Employee;
             _loadedSupplier = this.Supplier;
             _loadedCustomer = this.Customer;
             _loadedUnknown  = this.Unknown;
             _loadedAssignee = this.Assignee;
             _loadedReporter = this.Reporter;
             inTxn           = false;
         }
     }
     catch (Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Example #24
0
        public TurnOverObjectCollection GetByCustomerGreaterThanDate(DateTime date, CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers;

            try
            {
                if (customer == null)
                {
                    turnOvers = new TurnOverDataService().GetByGreaterThanDate(date);
                }
                else
                {
                    turnOvers = new TurnOverDataService().GetByCustomerGreaterThanDate(customer, date);
                }
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(turnOvers);
        }
Example #25
0
        public TurnOverObjectCollection GetByYear(int year, CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers;

            try
            {
                if (customer == null)
                {
                    turnOvers = new TurnOverDataService().GetByYear(year);
                }
                else
                {
                    turnOvers = new TurnOverDataService().GetByCustomerByYear(customer, year);
                }
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(turnOvers);
        }
Example #26
0
        public void Save(CustomerObject customer)
        {
            SqlCommand cmd = null;

            try
            {
                ExecuteNonQuery(out cmd, false, "Customer_SAVE",
                                CreateParameter("@cusID", SqlDbType.UniqueIdentifier, customer.CusID, ParameterDirection.InputOutput),
                                CreateParameter("@tasID", SqlDbType.Int, customer.TasID),
                                CreateParameter("@Name", SqlDbType.NChar, customer.Name),
                                CreateParameter("@Name2", SqlDbType.NChar, customer.Name2),
                                CreateParameter("@Street", SqlDbType.NChar, customer.Street),
                                CreateParameter("@HouseNumber", SqlDbType.NChar, customer.HouseNumber),
                                CreateParameter("@Zipcode", SqlDbType.NChar, customer.Zipcode),
                                CreateParameter("@Town", SqlDbType.NChar, customer.Town),
                                CreateParameter("@Country", SqlDbType.NChar, customer.Country),
                                CreateParameter("@VAT", SqlDbType.NChar, customer.Vat),
                                CreateParameter("@Phone", SqlDbType.NChar, customer.Phone),
                                CreateParameter("@Language", SqlDbType.NChar, customer.Language),
                                CreateParameter("@Currency", SqlDbType.NChar, customer.Currency)
                                );
                customer.CusID = (Guid)cmd.Parameters["cusID"].Value;
            }
            catch (Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                cmd = null;
            }
        }
Example #27
0
        public Decimal GetTurnOverByYearByCustomer(CustomerObject customer, int year)
        {
            TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
            Decimal    turnOver = new Decimal();
            SqlCommand cmd      = null;
            DataTable  dt;

            try
            {
                string query = "SELECT SUM(Turnover) "
                               + " FROM [TIS].[dbo].[TurnOverCustomer]"
                               + " WHERE tas_TNR_ID = " + customer.TasID + " AND Date >= '" + year + "0101' AND Date <= '" + year + "1231'";



                cmd             = new SqlCommand(query);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@TNR_ID", customer.TasID));
                cmd.Parameters.Add(new SqlParameter("@YEAR", year));
                dt = this.ExecuteNonQuery(cmd, false).Tables[0];

                if (dt.Rows[0][0].ToString() == "")
                {
                    turnOver = 0;
                }
                else
                {
                    turnOver = Convert.ToDecimal(dt.Rows[0][0].ToString());
                }
            }
            catch (System.Exception exception1)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
            }
            return(turnOver);
        }
Example #28
0
        public Decimal GetAverageTurnOverMonthByYearByCustomer(CustomerObject customer, int year)
        {
            TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
            Decimal turnOver = new Decimal();

            try
            {
                if (customer == null) //Average All
                {
                    return(GetAverageTurnOverMonthByYear(year));
                }
                else // Average Customer
                {
                    turnOvers = GetByCustomerByYear(customer, year);
                    for (int i = 0; i < turnOvers.Count; i++)
                    {
                        turnOver += turnOvers[i].TurnOver;
                    }
                    int months = 1;
                    if (year != System.DateTime.Now.Year)
                    {
                        months = 12;
                    }
                    else
                    {
                        months = System.DateTime.Now.Month;
                    }
                    turnOver = turnOver / months;
                }
            }
            catch (System.Exception exception1)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
            }
            return(turnOver);
        }
Example #29
0
        private void btn_del_update_Click(object sender, EventArgs e)
        {
            DeliveryObject objdel  = new DeliveryObject();
            CustomerObject objcus  = new CustomerObject();
            SalesObject    objInv  = new SalesObject();
            EmployeeObject objemp  = new EmployeeObject();
            VehicalObject  objvehi = new VehicalObject();



            //chechk whether text feilds are empty or not
            if (txtb_del_deliveryno.Text == "" || txtb_del_invoiceid.Text == "" || txtb_del_cusid.Text == "" || txtb_del_driver.Text == "" || txtb_del_vehicalno.Text == "" || comb_del_status.Text == "" || rtxtb_del_description.Text == "" || txtb_del_from.Text == "" || txtb_del_to.Text == "" || txtb_del_distance.Text == "" || txtb_del_rate.Text == "" || txtb_del_cost.Text == "")
            {
                MessageBox.Show("Please fill the all required feilds");
            }
            else
            {
                // objdel.DeliveryNo1 = txtb_del_deliveryno.Text;
                //  objInv.InvoiceID1 = Convert.ToInt32(txtb_del_invoiceid.Text);
                //  objcus.Nic = txtb_del_cusid.Text;
                objemp.empid        = Convert.ToInt32(txtb_del_driver.Text);
                objvehi.VehicalNo   = txtb_del_vehicalno.Text;
                objdel.Status1      = comb_del_status.Text;
                objdel.Description1 = rtxtb_del_description.Text;
                objdel.From1        = txtb_del_from.Text;
                objdel.To1          = txtb_del_to.Text;
                objdel.Distance1    = Convert.ToDouble(txtb_del_distance.Text);
                objdel.Rate1        = Convert.ToDouble(txtb_del_rate.Text);
                objdel.Cost1        = Convert.ToDouble(txtb_del_cost.Text);
                objdel.Date         = dtp_del_delDate.Value.Date;

                //show the confirmation dialog box
                DialogResult dr;
                dr = MessageBox.Show("Do you want to save the record", "Confirm", MessageBoxButtons.YesNo);
                string Dr = dr.ToString();

                if (Dr == "Yes")
                {
                    try
                    {
                        MegaCoolMethods mcm    = new MegaCoolMethods();
                        bool            result = mcm.AddNewdelivery(objdel, objcus, objInv, objemp, objvehi);


                        if (result)
                        {
                            MessageBox.Show("Successfully Saved", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            // FillMemberDetails();
                        }
                        else
                        {
                            MessageBox.Show("Unable to Save", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (ApplicationException appEx)
                    {
                        MessageBox.Show(appEx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    catch (SqlException ex)
                    {
                        if (ex.Number == 2627)
                        {
                            MessageBox.Show("This Delivery Number is already Exsists");
                        }
                    }

                    rbtn_del_delivery.Checked = true;
                    deliveryDELIVERYFillGrid();
                    deliveryProcessingDELIVERYFillGrid();
                    //else
                    //    MessageBox.Show("Data is not entered");

                    //deliveryFillGrid();
                    //vehi_clear();
                }
                //}
            }
        }
    private void CustImpFormHandler(SAPbouiCOM.Form form, SAPbouiCOM.ItemEvent pVal)
    {
        try
        {
            if (pVal.BeforeAction)
            {
            }
            else
            {
                switch (pVal.EventType)
                {
                case SAPbouiCOM.BoEventTypes.et_CLICK:

                    break;

                case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED:
                {
                    switch (pVal.ItemUID)
                    {
                    case btnClose:
                        oCustImpForm.Close();
                        break;

                    case btnImp:
                        try
                        {
                            if (custObjForImport == null)
                            {
                                form.Items.Item(btnFind).Click();
                            }
                            else
                            {
                                string cardcode = getComboBoxVal(form, cbCustomerID);
                                if (cardcode == "")
                                {
                                    showMessage("Please select a customer.");
                                }
                                else
                                {
                                    if (custObjForImport == null)
                                    {
                                        form.Items.Item(btnFind).Click();
                                    }
                                    else
                                    {
                                        if (SBO_Application.MessageBox("Import payment method(s) to " + cardcode + "?", 1, "Yes", "No") == 1)
                                        {
                                            int i = 0;
                                            foreach (PaymentMethod pm in custObjForImport.PaymentMethods)
                                            {
                                                if (!isPaymentMethodExists(cardcode, pm.CardNumber, pm.CardExpiration))
                                                {
                                                    CCCUST cccust = new CCCUST();
                                                    cccust.CustomerID = cardcode;
                                                    cccust.active     = 'Y';
                                                    cccust.email      = custObjForImport.BillingAddress.Email;
                                                    cccust.firstName  = custObjForImport.BillingAddress.FirstName;
                                                    cccust.lastName   = custObjForImport.BillingAddress.LastName;
                                                    cccust.street     = custObjForImport.BillingAddress.Street;
                                                    cccust.city       = custObjForImport.BillingAddress.City;
                                                    cccust.state      = custObjForImport.BillingAddress.State;
                                                    cccust.zip        = custObjForImport.BillingAddress.Zip;
                                                    cccust.expDate    = pm.CardExpiration;
                                                    cccust.cardCode   = pm.CardCode;

                                                    cccust.routingNumber   = pm.Routing;
                                                    cccust.checkingAccount = pm.Account;
                                                    cccust.GroupName       = getGroupName(cardcode);
                                                    cccust.CustNum         = custObjForImport.CustNum;
                                                    cccust.MethodID        = pm.MethodID;
                                                    try
                                                    {
                                                        if (pm.MethodName != null && pm.MethodName != "")
                                                        {
                                                            if (pm.MethodName.IndexOf(" ") > 0)
                                                            {
                                                                string   name = pm.MethodName;
                                                                string[] s    = name.Split(' ');

                                                                cccust.firstName = s[0];
                                                                cccust.lastName  = s[s.Length - 1];
                                                            }
                                                        }
                                                    }
                                                    catch (Exception) { }
                                                    int    id   = getNextTableID("@CCCUST");
                                                    string desc = cccust.firstName + " " + cccust.lastName;
                                                    if (pm.MethodName != null && pm.MethodName != "")
                                                    {
                                                        desc = pm.MethodName;
                                                    }
                                                    if (pm.MethodType == "check")
                                                    {
                                                        cccust.methodDescription = id.ToString() + "_" + pm.Routing + " " + pm.Account + "(" + desc + ")";
                                                        cccust.checkingAccount   = pm.Account;
                                                        cccust.routingNumber     = pm.Routing;
                                                    }
                                                    else
                                                    {
                                                        cccust.cardNum           = pm.CardNumber;
                                                        cccust.methodDescription = id.ToString() + "_" + pm.CardNumber + " " + pm.CardExpiration + "(" + desc + ")";
                                                        cccust.checkingAccount   = pm.Account;
                                                        cccust.cardType          = pm.CardType;
                                                    }
                                                    string cardid = "";
                                                    cccust.CardName    = getCardName(cccust.GroupName, cccust.cardType, "", ref cardid);
                                                    cccust.CCAccountID = cardid;
                                                    cccust.methodName  = pm.MethodName;
                                                    insert(cccust);
                                                    SBO_Application.SetStatusBarMessage(string.Format("Import payment method {0} to {1}.", cccust.cardNum, cardcode), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                                                }
                                                i++;
                                            }
                                        }
                                    }
                                }
                            }
                        }catch (Exception ex)
                        {
                            SBO_Application.SetStatusBarMessage(string.Format("Import payment method error: {0}.", ex.Message), SAPbouiCOM.BoMessageTime.bmt_Medium, true);
                        }
                        break;

                    case btnFind:
                        try
                        {
                            string custNum = getFormEditVal(form, editCustNum);
                            if (custNum == "")
                            {
                                showMessage("Please enter customer number.");
                            }
                            else
                            {
                                SBO_Application.SetStatusBarMessage("Finding customer please wait...", SAPbouiCOM.BoMessageTime.bmt_Medium, false);

                                ueSecurityToken token = getToken("");
                                custObjForImport = ebiz.getCustomer(token, custNum);
                                SAPbouiCOM.ComboBox oCB = (SAPbouiCOM.ComboBox)form.Items.Item(cbPaymentMethod).Specific;
                                try
                                {
                                    while (oCB.ValidValues.Count > 0)
                                    {
                                        oCB.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index);
                                    }
                                }
                                catch (Exception)
                                { }
                                ComboAddItem(oCB, "");
                                foreach (PaymentMethod pm in custObjForImport.PaymentMethods)
                                {
                                    string s    = "";
                                    string name = "";
                                    name = custObjForImport.BillingAddress.FirstName + " " + custObjForImport.BillingAddress.LastName;
                                    if (pm.MethodName != null && pm.MethodName != "")
                                    {
                                        if (pm.MethodName.IndexOf(" ") > 0)
                                        {
                                            name = pm.MethodName;
                                        }
                                    }
                                    if (pm.MethodType == "check")
                                    {
                                        s = pm.Routing + " " + pm.Account + "(" + name + ")";
                                    }
                                    else
                                    {
                                        s = pm.CardNumber + " " + pm.CardExpiration + "(" + name + ")";
                                    }
                                    ComboAddItem(oCB, s);
                                }
                                oCB.Select("");
                                SBO_Application.SetStatusBarMessage(string.Format("{0} payment method(s) ready to import.", oCB.ValidValues.Count - 1), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                                // form.Items.Item(btnImp).Click();
                            }
                        }catch (Exception ex)
                        {
                            custObjForImport = null;
                            SAPbouiCOM.ComboBox oCB = (SAPbouiCOM.ComboBox)form.Items.Item(cbPaymentMethod).Specific;
                            try
                            {
                                while (oCB.ValidValues.Count > 0)
                                {
                                    oCB.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index);
                                }
                            }
                            catch (Exception)
                            { }
                            ComboAddItem(oCB, "");
                            oCB.Select("");
                            SBO_Application.SetStatusBarMessage(string.Format("Find customer error: {0}.", ex.Message), SAPbouiCOM.BoMessageTime.bmt_Medium, true);

                            errorLog(ex);
                        }
                        break;
                    }
                }
                break;
                }
            }
        }
        catch (Exception ex)
        {
            errorLog(ex);
        }
    }