Пример #1
0
        public bool ingresoCliente()
        {
            DbCustomer customer = new DbCustomer();

            customer.CardNum                    = cardNum;
            customer.Description                = txtRazonSocial.Text;
            customer.Street                     = txtDireccion.Text;
            customer.Notes1                     = txtComuna.Text;
            customer.City                       = txtCiudad.Text;
            customer.Notes2                     = txtDirecPostal.Text;
            customer.Notes3                     = txtComPostal.Text;
            customer.Notes4                     = txtCiudadPostal.Text;
            customer.Type                       = DbCustomer.Types.Identification;
            customer.VisibilityCriteriaID       = 1;
            customer.PrepayPaymentID            = 4;
            customer.PrepayPricelevelID         = 1;
            customer.CreditPaymentID            = 4;
            customer.CreditPricelevelID         = 1;
            customer.IdentificationPricelevelID = 1;
            customer["passwd"]                  = "*";

            BL.DB.InsertCustomer(customer);


            if (BL.AddCustomer(null, customer.CardNum, true) == BLogic.AddCustomerResult.Ok)
            {
                BL.RefreshTransactionItems();
                return(true);
            }
            return(false);
        }
        }//FINISH PM_OnProcessUnknownIniParameter

        private void consultaCliente()
        {
            //if (true)
            //    return;
            if (BL.CurrentTransaction != null && BL.CurrentTransaction.Customer == null)
            {
                //USING FORM
                using (RutForm rutForm = new RutForm())
                {
                    rutForm.SetupForm(BL);
                    rutForm.Focus();
                    if (rutForm.ShowDialog() == DialogResult.OK)
                    {
                        rut = rutForm.txtRut.Text;
                        if (validaRut(rut))
                        {
                            //BL.MsgInfo("RUT VALIDO");
                        }
                        else
                        {
                            BL.MsgInfo("RUT NO VALIDO");
                            return;
                        }
                    }
                    else
                    {
                        customer = new DbCustomer();
                    }
                }
                //END USING FOMR

                KeypadParameters param = new KeypadParameters("");
                //KeypadResult result;

                if (rut == null)
                {
                    return;
                }
                rut = parseRUT(rut);
                string myCustomer = SafeConvert.ToString(BL.DB.CentralDbExecuteScalar("SELECT card_num FROM customers WHERE card_num = " + SqlHelper.Quote(rut)));

                customer = null;
                if (myCustomer != "")
                {
                    customer = BL.DB.GetCustomerByCardNum(myCustomer, false);
                }
                if (customer == null)
                {
                    customer = BL.DB.GetCustomerByCardNum(rut, false);
                }

                if (customer != null)
                {
                    BL.AddCustomer(null, customer.CardNum, true);
                    BL.RefreshTransactionItems();
                }
                else
                {
                    if (BL.MsgQuestion("Cliente no exite, deseas crearlo?", 5) == true)
                    {
                        //INICIO FORMULARIO NUEVO CLIENTE
                        BL.MsgWarning("Has Decidido Guardar al Cliente");
                        using (NewCustomerForm customerForm = new NewCustomerForm())
                        {
                            customerForm.SetupForm(BL, rut);
                            customerForm.Focus();
                            if (customerForm.ShowDialog() == DialogResult.OK)
                            {
                            }
                        }
                        //FIN INGRESO FORMULARIO NUEVO CLIENTE
                    }
                    else
                    {
                        BL.MsgInfo("Has Decidido NO guardar al Cliente");
                        return;
                    }
                }
            }
        }