Пример #1
0
        /// <summary>
        /// Creates a new instance of the sol_Customers class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sol_Customer MakeSol_Customer(SqlDataReader dataReader)
        {
            Sol_Customer sol_Customer = new Sol_Customer();

            sol_Customer.CustomerID        = SqlClientUtility.GetInt32(dataReader, "CustomerID", 0);
            sol_Customer.CustomerCode      = SqlClientUtility.GetString(dataReader, "CustomerCode", String.Empty);
            sol_Customer.Name              = SqlClientUtility.GetString(dataReader, "Name", String.Empty);
            sol_Customer.Contact           = SqlClientUtility.GetString(dataReader, "Contact", String.Empty);
            sol_Customer.Address1          = SqlClientUtility.GetString(dataReader, "Address1", String.Empty);
            sol_Customer.Address2          = SqlClientUtility.GetString(dataReader, "Address2", String.Empty);
            sol_Customer.City              = SqlClientUtility.GetString(dataReader, "City", String.Empty);
            sol_Customer.Province          = SqlClientUtility.GetString(dataReader, "Province", String.Empty);
            sol_Customer.Country           = SqlClientUtility.GetString(dataReader, "Country", String.Empty);
            sol_Customer.PostalCode        = SqlClientUtility.GetString(dataReader, "PostalCode", String.Empty);
            sol_Customer.Email             = SqlClientUtility.GetString(dataReader, "Email", String.Empty);
            sol_Customer.LoweredEmail      = SqlClientUtility.GetString(dataReader, "LoweredEmail", String.Empty);
            sol_Customer.IsActive          = SqlClientUtility.GetBoolean(dataReader, "IsActive", false);
            sol_Customer.PhoneNumber       = SqlClientUtility.GetString(dataReader, "PhoneNumber", String.Empty);
            sol_Customer.Notes             = SqlClientUtility.GetString(dataReader, "Notes", String.Empty);
            sol_Customer.Password          = SqlClientUtility.GetString(dataReader, "Password", String.Empty);
            sol_Customer.DepotID           = SqlClientUtility.GetString(dataReader, "DepotID", String.Empty);
            sol_Customer.CardNumber        = SqlClientUtility.GetString(dataReader, "CardNumber", String.Empty);
            sol_Customer.CardTypeID        = SqlClientUtility.GetInt32(dataReader, "CardTypeID", 0);
            sol_Customer.SolumCustomer     = SqlClientUtility.GetBoolean(dataReader, "SolumCustomer", false);
            sol_Customer.QuickDropCustomer = SqlClientUtility.GetBoolean(dataReader, "QuickDropCustomer", false);
            //sol_Customer.IsNew = SqlClientUtility.GetBoolean(dataReader, "IsNew", false);

            return(sol_Customer);
        }
Пример #2
0
        /// <summary>
        /// Updates a record in the sol_Customers table.
        /// </summary>
        public virtual void Update(Sol_Customer sol_Customer)
        {
            ValidationUtility.ValidateArgument("sol_Customer", sol_Customer);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@CustomerID", sol_Customer.CustomerID),
                new SqlParameter("@CustomerCode", sol_Customer.CustomerCode),
                new SqlParameter("@Name", sol_Customer.Name),
                new SqlParameter("@Contact", sol_Customer.Contact),
                new SqlParameter("@Address1", sol_Customer.Address1),
                new SqlParameter("@Address2", sol_Customer.Address2),
                new SqlParameter("@City", sol_Customer.City),
                new SqlParameter("@Province", sol_Customer.Province),
                new SqlParameter("@Country", sol_Customer.Country),
                new SqlParameter("@PostalCode", sol_Customer.PostalCode),
                new SqlParameter("@Email", sol_Customer.Email),
                new SqlParameter("@LoweredEmail", sol_Customer.LoweredEmail),
                new SqlParameter("@IsActive", sol_Customer.IsActive),
                new SqlParameter("@PhoneNumber", sol_Customer.PhoneNumber),
                new SqlParameter("@Notes", sol_Customer.Notes),
                new SqlParameter("@Password", sol_Customer.Password),
                new SqlParameter("@DepotID", sol_Customer.DepotID),
                new SqlParameter("@CardNumber", sol_Customer.CardNumber),
                new SqlParameter("@CardTypeID", sol_Customer.CardTypeID),
                new SqlParameter("@SolumCustomer", sol_Customer.SolumCustomer),
                new SqlParameter("@QuickDropCustomer", sol_Customer.QuickDropCustomer)
                //            ,
                //new SqlParameter("@IsNew", sol_Customer.IsNew)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "sol_Customers_Update", parameters);
        }
Пример #3
0
        /// <summary>
        /// Selects all records from the sol_Customers table.
        /// </summary>
        public virtual List <Sol_Customer> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Customers_SelectAll"))
            {
                List <Sol_Customer> sol_CustomerList = new List <Sol_Customer>();
                while (dataReader.Read())
                {
                    Sol_Customer sol_Customer = MakeSol_Customer(dataReader);
                    sol_CustomerList.Add(sol_Customer);
                }

                return(sol_CustomerList);
            }
        }
Пример #4
0
        /// <summary>
        /// Selects all records from the sol_Customers table by a foreign key.
        /// </summary>
        public virtual List <Sol_Customer> _SelectAllByCardTypeID(int cardTypeID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@CardTypeID", cardTypeID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Customers_SelectAllByCardTypeID", parameters))
            {
                List <Sol_Customer> sol_CustomerList = new List <Sol_Customer>();
                while (dataReader.Read())
                {
                    Sol_Customer sol_Customer = MakeSol_Customer(dataReader);
                    sol_CustomerList.Add(sol_Customer);
                }

                return(sol_CustomerList);
            }
        }
Пример #5
0
        private void ReadDrops(bool MineOnly)
        {
            listViewDrops.Items.Clear();

            string orderType = String.Empty;

            if (checkBoxMissingBags.Checked)
            {
                orderType = "M";
            }
            else
            {
                orderType = "Q";
            }

            //qds_DropList = qds_Drop_Sp.SelectAllInProcess();
            qds_DropList = qds_Drop_Sp.SelectAllByOrderTpe(orderType);
            if (qds_DropList != null)
            {
                if (buttonBags.Text == "&Unselect all")
                {
                    buttonBags.Text = "&Select all";
                }
            }


            Guid UserId = new Guid();

            if (MineOnly)
            {
                if (sol_Order_Sp == null)
                {
                    sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
                }

                MembershipUser UserAccount = Membership.GetUser();
                UserId = (Guid)UserAccount.ProviderUserKey;
            }

            //dropID
            //customer
            //bags
            //paymentMethod
            //depotID
            //orderID

            foreach (Qds_Drop or in qds_DropList)
            {
                if (MineOnly)
                {
                    //is not user's order if does not exist
                    if (or.OrderID < 1)
                    {
                        continue;
                    }

                    sol_Order = sol_Order_Sp.Select(or.OrderID, or.OrderType);
                    //is not user's order if does not exist
                    if (sol_Order == null)
                    {
                        continue;
                    }

                    if (UserId != null)
                    {
                        if (UserId != sol_Order.UserID)
                        {
                            continue;
                        }
                    }
                }

                int    dropID   = or.DropID;
                string customer = or.CustomerID.ToString();
                sol_Customer = sol_Customer_Sp.Select(or.CustomerID);
                if (sol_Customer != null)
                {
                    customer = sol_Customer.Name;
                }

                int bags = or.NumberOfBags;

                string paymentMethod = or.PaymentMethodID.ToString();
                qds_PaymentMethod = qds_PaymentMethod_Sp.Select(or.PaymentMethodID);
                if (qds_PaymentMethod != null)
                {
                    paymentMethod = qds_PaymentMethod.PaymentMethod;
                }

                string depotID = or.DepotID;
                int    orderID = or.OrderID;

                addDropItem(dropID, customer, bags, paymentMethod, depotID, orderID, or.OrderType);
            }
        }
Пример #6
0
        private void UpdateOrders()
        {
            //bool firstTime = true;
            int    orderId   = 0;
            string orderType = "";

            totalPaidOrders = 0;

            Sol_Order_Sp            sol_Order_Sp         = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_OrdersDetail        sol_OrdersDetail     = new Sol_OrdersDetail();
            Sol_OrdersDetail_Sp     sol_OrdersDetail_Sp  = new Sol_OrdersDetail_Sp(Properties.Settings.Default.WsirDbConnectionString);
            List <Sol_OrdersDetail> sol_OrdersDetailList = new List <Sol_OrdersDetail>();

            //items
            ListView.ListViewItemCollection Items = listView1.Items;
            foreach (ListViewItem item in Items)
            {
                if (!Int32.TryParse(item.SubItems[0].Text, out orderId))
                {
                    MessageBox.Show("We couldn't parse Order " + item.SubItems[0].Text);
                    continue;
                }

                orderType = item.SubItems[4].Text;


                //read order
                Sol_Order sol_Order = sol_Order_Sp.Select(orderId, orderType);

                //not found?
                if (sol_Order == null)
                {
                    MessageBox.Show(String.Format("Order #{0} not found!", orderId));
                    continue;
                }


                //marked as paid
                if (onAccount)
                {
                    //search for customer data if its on account
                    Sol_Customer    sol_Customer    = new Sol_Customer();
                    Sol_Customer_Sp sol_Customer_Sp = new Sol_Customer_Sp(Properties.Settings.Default.WsirDbConnectionString);
                    sol_Customer         = sol_Customer_Sp.Select(customerId);
                    sol_Order.CustomerID = customerId;
                    //sol_Order.Name = sol_Customer.Name;
                    //sol_Order.Address1 = sol_Customer.Address1;
                    //sol_Order.Address2 = sol_Customer.Address2;
                    //sol_Order.City = sol_Customer.City;
                    //sol_Order.Province = sol_Customer.Province;
                    //sol_Order.Country = sol_Customer.Country;
                    //sol_Order.PostalCode = sol_Customer.PostalCode;

                    sol_Order.Status = "O"; //O = On account
                    //sol_Order_Sp.Update(sol_Order);
                }
                else
                {
                    sol_Order.DatePaid = Main.rc.FechaActual;
                    sol_Order.Status   = "P"; //paid, processed
                }

                //close order if it is not
                if (sol_Order.DateClosed < sol_Order.Date)
                {
                    sol_Order.DateClosed = Main.rc.FechaActual;
                }


                sol_Order_Sp.Update(sol_Order);

                totalPaidOrders = totalPaidOrders + sol_Order.TotalAmount - sol_Order.FeeAmount;

                //close order if it is not
                if (sol_Order.DateClosed < sol_Order.Date)
                {
                    sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");
                }

                //paid
                if (!onAccount)
                {
                    sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DatePaid");
                }


                //mark details
                sol_OrdersDetailList = sol_OrdersDetail_Sp._SelectAllByOrderID_OrderType(orderId, orderType);
                foreach (Sol_OrdersDetail od in sol_OrdersDetailList)
                {
                    sol_OrdersDetail        = sol_OrdersDetail_Sp.Select(od.DetailID);
                    sol_OrdersDetail.Status = sol_Order.Status;
                    sol_OrdersDetail_Sp.Update(sol_OrdersDetail);
                }


                if (Main.CardReader_Enabled)
                {
                    UpdateOrderCardLink(orderId);
                }
            }
        }
Пример #7
0
        private void bindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (b_Accion == "agregar")
            {
                if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolAddCatalogues", true))
                {
                    return;
                }
            }
            else
            {
                if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolEditCatalogues", true))
                {
                    return;
                }
            }

            //check data
            //name
            fieldNameTextBox.Text = fieldNameTextBox.Text.Trim();
            if (!Funciones.ValidateText(fieldNameTextBox, ref errorProvider1))
            {
                fieldNameTextBox.Focus();
                return;
            }

            //quickdrop
            if (quickDropCustomerCheckBox.Checked)
            {
                //this.Validate();
                //this.BindingSource1.EndEdit();


                //cardNumberTextBox
                if (String.IsNullOrEmpty(cardNumberTextBox.Text))
                {
                    MessageBox.Show("Enter a card number please!");
                    cardNumberTextBox.Focus();
                    return;
                }


                //aqui
                if (formerCardNumber != cardNumberTextBox.Text)
                {
                    if (sol_Customer_Sp == null)
                    {
                        sol_Customer_Sp = new Sol_Customer_Sp(Properties.Settings.Default.WsirDbConnectionString);
                    }

                    sol_Customer = sol_Customer_Sp.SelectByCardNumber(cardNumberTextBox.Text);
                    if (sol_Customer != null)
                    {
                        MessageBox.Show("Card number already used, try another please!");
                        cardNumberTextBox.Focus();
                        return;
                    }
                }
            }


            this.Validate();
            this.BindingSource1.EndEdit();

            this.TableAdapterManager.UpdateAll(this.DataSet1);

            //goto last row
            try
            {
                if (b_Accion == "agregar")
                {
                    this.TableAdapter1.Fill(this.DataSet1.sol_Customers, customerType, textBoxName.Text, activeType);
                    this.BindingSource1.MoveLast();
                }
            }
            catch
            {
                //
            }

            b_Accion    = "";
            OK.Text     = "&Select";
            Cancel.Text = "&Close";

            cambiarVista();
        }