public void UpsertDailyOrders(DailyOrders dailyOrders)
        {
            //Connection and Command objects.
            MySqlConnection con = new MySqlConnection(ConnectionString);
            MySqlCommand    com = new MySqlCommand("UpsertDailyOrders", con);

            com.CommandType = System.Data.CommandType.StoredProcedure;
            //Procedure Parameters.
            com.Parameters.Add(new MySqlParameter("VarPIN", dailyOrders.ID));
            com.Parameters.Add(new MySqlParameter("VarPIN", dailyOrders.PIN));
            com.Parameters.Add(new MySqlParameter("VarEmployeeID", dailyOrders.EmployeeID));
            com.Parameters.Add(new MySqlParameter("VarFirstName", dailyOrders.FirstName));
            com.Parameters.Add(new MySqlParameter("VarLastName", dailyOrders.LastName));
            com.Parameters.Add(new MySqlParameter("VarDeptName", dailyOrders.DeptName));
            com.Parameters.Add(new MySqlParameter("VarDeptCode", dailyOrders.DeptCode));
            com.Parameters.Add(new MySqlParameter("VarJobTitle", dailyOrders.JobTitle));
            com.Parameters.Add(new MySqlParameter("VarPhoneNumber", dailyOrders.PhoneNumber));
            com.Parameters.Add(new MySqlParameter("VarCatalogName", dailyOrders.CatalogName));
            com.Parameters.Add(new MySqlParameter("VarRewardName", dailyOrders.RewardName));
            com.Parameters.Add(new MySqlParameter("VarQuantity", dailyOrders.Quantity));
            com.Parameters.Add(new MySqlParameter("VarDetails", dailyOrders.Details));
            com.Parameters.Add(new MySqlParameter("VarHighestLevelCategory", dailyOrders.HighestLevelCategory));
            com.Parameters.Add(new MySqlParameter("VarLowestLevelCategory", dailyOrders.LowestLevelCategory));
            com.Parameters.Add(new MySqlParameter("VarCompany", dailyOrders.Company));
            com.Parameters.Add(new MySqlParameter("VarName", dailyOrders.Name));
            com.Parameters.Add(new MySqlParameter("VarAddress1", dailyOrders.Address1));
            com.Parameters.Add(new MySqlParameter("VarAddress2", dailyOrders.Address2));
            com.Parameters.Add(new MySqlParameter("VarCity", dailyOrders.City));
            com.Parameters.Add(new MySqlParameter("VarState", dailyOrders.State));
            com.Parameters.Add(new MySqlParameter("VarZipCode", dailyOrders.ZipCode));
            com.Parameters.Add(new MySqlParameter("VarCountry", dailyOrders.Country));
            com.Parameters.Add(new MySqlParameter("VarP2MOrderNumber", dailyOrders.P2MOrderNumber));
            com.Parameters.Add(new MySqlParameter("VarStatus", dailyOrders.OrderStatus));
            com.Parameters.Add(new MySqlParameter("VarCStatus", dailyOrders.OrderCStatus));
            com.Parameters.Add(new MySqlParameter("VarDiscountCoupon", dailyOrders.DiscountCoupon));
            com.Parameters.Add(new MySqlParameter("VarRedemptionAmount", dailyOrders.RedemptionAmount));
            com.Parameters.Add(new MySqlParameter("VarDiscountApplied", dailyOrders.DiscountApplied));
            com.Parameters.Add(new MySqlParameter("VarMemberPaid", dailyOrders.MemberPaid));
            com.Parameters.Add(new MySqlParameter("VarPointBillingRate", dailyOrders.PointBillingRate));
            com.Parameters.Add(new MySqlParameter("VarordarDate", dailyOrders.OrderDate));
            com.Parameters.Add(new MySqlParameter("VarGRSOrderNum", dailyOrders.GRSOrderNum));
            com.Parameters.Add(new MySqlParameter("VarItemNumber", dailyOrders.ItemNumber));
            com.Parameters.Add(new MySqlParameter("VarItemDescription", dailyOrders.ItemDescription));
            com.Parameters.Add(new MySqlParameter("VarItemOption", dailyOrders.ItemOption));
            com.Parameters.Add(new MySqlParameter("VarEmail", dailyOrders.Email));
            com.Parameters.Add(new MySqlParameter("VarProductCost", dailyOrders.ProductCost));
            com.Parameters.Add(new MySqlParameter("VarCatalogCode", dailyOrders.CatalogCode));
            com.Parameters.Add(new MySqlParameter("VarDateProcessed", dailyOrders.DateProcessed));
            com.Parameters.Add(new MySqlParameter("VarQuantityShipped", dailyOrders.QuantityShipped));
            com.Parameters.Add(new MySqlParameter("VarTrackingNumber", dailyOrders.TrackingNumber));
            com.Parameters.Add(new MySqlParameter("VarCourierName", dailyOrders.CourierName));
            com.Parameters.Add(new MySqlParameter("VarMemo", dailyOrders.Memo));
            com.Parameters.Add(new MySqlParameter("VarNote", dailyOrders.Note));

            //
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
        }
Пример #2
0
        protected void gvDailyorders_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DailyOrdersDAL ONSODAL = new DailyOrdersDAL();

            ONSODAL.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConn"].ToString();
            DailyOrders DO   = new DailyOrders();
            string      name = (gvDailyorders.Rows[e.RowIndex].FindControl("lblName") as Label).Text;

            DO.ID             = (gvDailyorders.Rows[e.RowIndex].FindControl("lblID") as Label).Text;
            DO.RewardName     = (gvDailyorders.Rows[e.RowIndex].FindControl("lblRName") as Label).Text;
            DO.Quantity       = Convert.ToInt32((gvDailyorders.Rows[e.RowIndex].FindControl("lblQuantity") as Label).Text);
            DO.FirstName      = name.Split(' ')[0];
            DO.LastName       = name.Split(' ')[1];;
            DO.OrderStatus    = (gvDailyorders.Rows[e.RowIndex].FindControl("lblStatus") as Label).Text;
            DO.OrderDate      = Convert.ToDateTime((gvDailyorders.Rows[e.RowIndex].FindControl("lblODate") as Label).Text);
            DO.P2MOrderNumber = (gvDailyorders.Rows[e.RowIndex].FindControl("lblP2M") as Label).Text;
            DO.Note           = (gvDailyorders.Rows[e.RowIndex].FindControl("tbNote") as TextBox).Text;
        }
        public List <DailyOrders> GetOrders(string ID)
        {
            MySqlConnection con = new MySqlConnection(ConnectionString);

            try
            {
                MySqlCommand com = new MySqlCommand("GetDailyOrders", con);
                com.CommandType = System.Data.CommandType.StoredProcedure;
                List <DailyOrders> DailyOrdersList = new List <DailyOrders>();
                com.Parameters.Add(new MySqlParameter("VarID", ID));

                con.Open();
                MySqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    DailyOrders dailyOrders = new DailyOrders();

                    dailyOrders.ID                   = reader["ID"].ToString();
                    dailyOrders.PIN                  = reader["PIN"].ToString();
                    dailyOrders.EmployeeID           = reader["EmployeeID"].ToString();
                    dailyOrders.FirstName            = reader["FirstName"].ToString() + " " + reader["LastName"].ToString();
                    dailyOrders.LastName             = reader["FirstName"].ToString() + " " + reader["LastName"].ToString();
                    dailyOrders.DeptName             = reader["DeptName"].ToString();
                    dailyOrders.DeptCode             = reader["DeptCode"].ToString();
                    dailyOrders.JobTitle             = reader["JobTitle"].ToString();
                    dailyOrders.PhoneNumber          = reader["PhoneNumber"].ToString();
                    dailyOrders.CatalogName          = reader["CatalogName"].ToString();
                    dailyOrders.RewardName           = string.IsNullOrEmpty(reader["RewardName"].ToString()) ? reader["ItemDescription"].ToString() : reader["RewardName"].ToString();
                    dailyOrders.Quantity             = Convert.ToInt32(reader["Quantity"]);
                    dailyOrders.Details              = reader["Details"].ToString();
                    dailyOrders.HighestLevelCategory = reader["HighestLevelCategory"].ToString();
                    dailyOrders.LowestLevelCategory  = reader["LowestLevelCategory"].ToString();
                    dailyOrders.Company              = reader["Company"].ToString();
                    dailyOrders.Name                 = reader["Name"].ToString();
                    dailyOrders.Address1             = reader["Address1"].ToString();
                    dailyOrders.Address2             = reader["Address2"].ToString();
                    dailyOrders.City                 = reader["City"].ToString();
                    dailyOrders.State                = reader["State"].ToString();
                    dailyOrders.ZipCode              = reader["ZipCode"].ToString();
                    dailyOrders.Country              = reader["Country"].ToString();
                    dailyOrders.P2MOrderNumber       = string.IsNullOrEmpty(reader["P2MOrderNumber"].ToString()) ? reader["GRSOrderNum"].ToString() : reader["P2MOrderNumber"].ToString();
                    if (!(string.IsNullOrEmpty(reader["GRSOrderNum"].ToString())) && ((reader["Status"].ToString()).ToLower() == "po_received"))
                    {
                        dailyOrders.OrderStatus = "shipped";
                    }
                    else
                    {
                        dailyOrders.OrderStatus = reader["Status"].ToString();
                    }
                    dailyOrders.OrderCStatus     = reader["CStatus"].ToString();
                    dailyOrders.DiscountCoupon   = reader["DiscountCoupon"].ToString();
                    dailyOrders.RedemptionAmount = Convert.ToDouble(reader["RedemptionAmount"].ToString());
                    dailyOrders.DiscountApplied  = reader["DiscountApplied"].ToString();
                    dailyOrders.MemberPaid       = reader["MemberPaid"].ToString();
                    dailyOrders.PointBillingRate = Convert.ToDouble(reader["PointBillingRate"]);
                    DateTime?OrderDate = (reader["OrderDate"] == System.DBNull.Value) ? (DateTime?)null : Convert.ToDateTime(reader["OrderDate"]);
                    dailyOrders.OrderDate   = OrderDate;
                    dailyOrders.GRSOrderNum = reader["GRSOrderNum"].ToString();
                    //dailyOrders.PartnerSystemOrderNum = reader["PartnerSystemOrderNum"].ToString();
                    dailyOrders.ItemNumber      = reader["ItemNumber"].ToString();
                    dailyOrders.ItemDescription = string.IsNullOrEmpty(reader["ItemDescription"].ToString())? reader["RewardName"].ToString(): reader["ItemDescription"].ToString();
                    dailyOrders.ItemOption      = reader["ItemOption"].ToString();
                    dailyOrders.Email           = reader["Email"].ToString();
                    dailyOrders.ProductCost     = Convert.ToDouble(reader["ProductCost"]);
                    dailyOrders.CatalogCode     = reader["CatalogCode"].ToString();
                    DateTime?DateProcessed = (reader["DateProcessed"] == System.DBNull.Value) ? (DateTime?)null : Convert.ToDateTime(reader["DateProcessed"]);
                    dailyOrders.DateProcessed   = DateProcessed;
                    dailyOrders.QuantityShipped = Convert.ToInt32(reader["QuantityShipped"]);
                    dailyOrders.TrackingNumber  = reader["TrackingNumber"].ToString();
                    dailyOrders.CourierName     = reader["CourierName"].ToString();
                    dailyOrders.Memo            = reader["Memo"].ToString();
                    dailyOrders.Note            = reader["Note"].ToString();
                    //TimeSpan span = DateTime.Now.Subtract((Convert.ToDateTime(reader["OrderDate"])));
                    //int delayed = span.Days;
                    //dailyOrders.delayed = delayed;



                    DailyOrdersList.Add(dailyOrders);
                }
                con.Close();
                return(DailyOrdersList);
            }
            catch
            {
                con.Close();
                return(null);
            }
        }