Example #1
0
 public static SalesCenter GetSalesCenterBySalesCenterId(int SalesCenterId)
 {
     SalesCenter salesCenter = new SalesCenter();
     SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();
     salesCenter = sqlSalesCenterProvider.GetSalesCenterBySalesCenterId(SalesCenterId);
     return salesCenter;
 }
    private void showSalesCenterData()
    {
        SalesCenter salesCenter = new SalesCenter();

        salesCenter             = SalesCenterManager.GetSalesCenterBySalesCenterId(Int32.Parse(Request.QueryString["ID"]));
        txtSalesCenterName.Text = salesCenter.SalesCenterName.ToString();
    }
Example #3
0
    public static SalesCenter GetSalesCenterBySalesCenterId(int SalesCenterId)
    {
        SalesCenter            salesCenter            = new SalesCenter();
        SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();

        salesCenter = sqlSalesCenterProvider.GetSalesCenterBySalesCenterId(SalesCenterId);
        return(salesCenter);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SalesCenter salesCenter = new SalesCenter();

//	salesCenter.SalesCenterId=  int.Parse(txtSalesCenterId.Text);
        salesCenter.SalesCenterName = txtSalesCenterName.Text;
        int resutl = SalesCenterManager.InsertSalesCenter(salesCenter);

        Response.Redirect("AdminDisplaySalesCenter.aspx");
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        SalesCenter salesCenter = new SalesCenter();

        salesCenter.SalesCenterId   = int.Parse(Request.QueryString["ID"].ToString());
        salesCenter.SalesCenterName = txtSalesCenterName.Text;
        bool resutl = SalesCenterManager.UpdateSalesCenter(salesCenter);

        Response.Redirect("AdminDisplaySalesCenter.aspx");
    }
Example #6
0
        public VentasCentro <CustomerRate> FillSalesCenter(VentasCentro <CustomerRate> ventasCentro, int mode = -1)
        {
            foreach (CustomerRate customer in ventasCentro.Items)
            {
                List <SalesCenter> oSales = new List <SalesCenter>();
                foreach (LabelAndValue <DateTime> date in ventasCentro.Dates)
                {
                    if (mode == 1)
                    {
                        SalesCenter sale = customer.SalesCenters.SingleOrDefault(o => o.PostingDate.Value.Day == date.Value.Day && o.PostingDate >= customer.StartingDate && (o.PostingDate <= customer.EndingDate || customer.EndingDate == null));
                        if (sale == null)
                        {
                            oSales.Add(new SalesCenter());
                        }
                        else
                        {
                            oSales.Add(sale);
                        }
                    }
                    else if (mode == 7)
                    {
                        SalesCenter weekSale = new SalesCenter()
                        {
                            Quantity = 0
                        };
                        foreach (SalesCenter sales in customer.SalesCenters)
                        {
                            if (sales.PostingDate.Value >= date.Value && sales.PostingDate.Value <= Convert.ToDateTime(date.Data))
                            {
                                weekSale.Quantity += sales.Quantity;
                            }
                        }
                        oSales.Add(weekSale);
                    }
                    else if (mode == 12)
                    {
                        SalesCenter monthSale = new SalesCenter()
                        {
                            Quantity = 0
                        };
                        foreach (SalesCenter sales in customer.SalesCenters)
                        {
                            if (sales.PostingDate.Value >= date.Value && sales.PostingDate.Value <= new DateTime(date.Value.Year, date.Value.Month, DateTime.DaysInMonth(date.Value.Year, date.Value.Month)))
                            {
                                monthSale.Quantity += sales.Quantity;
                            }
                        }
                        oSales.Add(monthSale);
                    }
                }
                customer.SalesCenters = oSales;
            }

            return(ventasCentro);
        }
Example #7
0
 public SalesCenter_View(SalesCenter s)
 {
     EntryNo       = s.EntryNo;
     CenterCode    = s.CenterCode ?? "";
     CustomerNo    = s.CustomerNo ?? "";
     ItemNo        = s.ItemNo ?? "";
     PostingDate   = s.PostingDate.Value.ToString("dd MMMM dddd") ?? DateTimeOffset.MinValue.ToString();
     Quantity      = s.Quantity ?? 0;
     PostingStatus = s.PostingStatus ?? "";
     ReadingDate   = s.ReadingDate ?? DateTimeOffset.MinValue;
     Amount        = s.Amount ?? 0;
 }
Example #8
0
    public bool UpdateSalesCenter(SalesCenter salesCenter)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateSalesCenter", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@SalesCenterId", SqlDbType.Int).Value        = salesCenter.SalesCenterId;
            cmd.Parameters.Add("@SalesCenterName", SqlDbType.NVarChar).Value = salesCenter.SalesCenterName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return(result == 1);
        }
    }
Example #9
0
    public int InsertSalesCenter(SalesCenter salesCenter)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("InsertSalesCenter", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@SalesCenterId", SqlDbType.Int).Direction    = ParameterDirection.Output;
            cmd.Parameters.Add("@SalesCenterName", SqlDbType.NVarChar).Value = salesCenter.SalesCenterName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return((int)cmd.Parameters["@SalesCenterId"].Value);
        }
    }
Example #10
0
        public ResultAndError <SalesCenter> Add(SalesCenter c)
        {
            ResultAndError <SalesCenter> result = new ResultAndError <SalesCenter>();

            try
            {
                db.SalesCenters.Add(c);
                db.SaveChanges();
                return(result.AddResult(c));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #11
0
        public bool DeleteMulti(IEnumerable <string> SalesCenters)
        {
            List <SalesCenter> oSalesCenters = new List <SalesCenter>();

            foreach (string SalesCenterNo in SalesCenters)
            {
                SalesCenter oSalesCenter = Get(SalesCenterNo);
                if (oSalesCenter != null)
                {
                    oSalesCenters.Add(oSalesCenter);
                }
            }
            db.SalesCenters.RemoveRange(oSalesCenters);
            db.SaveChanges();
            return(true);
        }
Example #12
0
    public SalesCenter GetSalesCenterFromReader(IDataReader reader)
    {
        try
        {
            SalesCenter salesCenter = new SalesCenter
                                      (

                DataAccessObject.IsNULL <int>(reader["SalesCenterId"]),
                DataAccessObject.IsNULL <string>(reader["SalesCenterName"])
                                      );
            return(salesCenter);
        }
        catch (Exception ex)
        {
            return(null);
        }
    }
Example #13
0
 public bool UpdateMulti(IEnumerable <SalesCenter> oSalesCenters, bool insertIfNoExists = false)
 {
     foreach (SalesCenter SalesCenter in oSalesCenters)
     {
         SalesCenter old = Get(SalesCenter.ItemNo);
         if (old == null && insertIfNoExists)
         {
             Add(SalesCenter);
         }
         else
         {
             db.Entry(old).CurrentValues.SetValues(SalesCenter);
         }
     }
     db.SaveChanges();
     return(true);
 }
Example #14
0
        public ResultAndError <bool> UpdateReadingDate(IEnumerable <int> centersNo, DateTimeOffset readingDate)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                foreach (int no in centersNo)
                {
                    SalesCenter oSalesCenter = Get(no.ToString());
                    oSalesCenter.ReadingDate = readingDate;
                    db.SaveChanges();
                }
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #15
0
        public ResultAndError <SalesCenter> Update(SalesCenter cr, bool insertIfNoExists = false)
        {
            ResultAndError <SalesCenter> result = new ResultAndError <SalesCenter>();

            try
            {
                SalesCenter old = Get(cr.ItemNo);
                if (old == null && insertIfNoExists)
                {
                    return(Add(cr));
                }
                db.Entry(old).CurrentValues.SetValues(cr);
                db.SaveChanges();
                return(result.AddResult(cr));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #16
0
        public ResultAndError <bool> Delete(string id)
        {
            ResultAndError <bool> result = new ResultAndError <bool>();

            try
            {
                SalesCenter SalesCenter = Get(id);
                if (SalesCenter == null)
                {
                    return(result.AddError("No se encontro la tarifa con el id " + id));
                }
                db.SalesCenters.Remove(SalesCenter);
                db.SaveChanges();
                return(result.AddResult(true));
            }
            catch (Exception e)
            {
                return(result.AddError(e, HttpStatusCode.InternalServerError));
            }
        }
Example #17
0
    public SalesCenter GetSalesCenterFromReader(IDataReader reader)
    {
        try
        {
            SalesCenter salesCenter = new SalesCenter
                (

                     DataAccessObject.IsNULL<int>(reader["SalesCenterId"]),
                     DataAccessObject.IsNULL<string>(reader["SalesCenterName"])
                );
             return salesCenter;
        }
        catch(Exception ex)
        {
            return null;
        }
    }
Example #18
0
    public bool UpdateSalesCenter(SalesCenter salesCenter)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateSalesCenter", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@SalesCenterId", SqlDbType.Int).Value = salesCenter.SalesCenterId;
            cmd.Parameters.Add("@SalesCenterName", SqlDbType.NVarChar).Value = salesCenter.SalesCenterName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
Example #19
0
    public static int InsertSalesCenter(SalesCenter salesCenter)
    {
        SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();

        return(sqlSalesCenterProvider.InsertSalesCenter(salesCenter));
    }
Example #20
0
 public IActionResult UpdSalesCenter([FromBody] SalesCenter SalesCenter, bool insertIfNoExists = false)
 {
     return(Ok(sBS.Update(SalesCenter, insertIfNoExists)));
 }
Example #21
0
 public static bool UpdateSalesCenter(SalesCenter salesCenter)
 {
     SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();
     return sqlSalesCenterProvider.UpdateSalesCenter(salesCenter);
 }
Example #22
0
 public static int InsertSalesCenter(SalesCenter salesCenter)
 {
     SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();
     return sqlSalesCenterProvider.InsertSalesCenter(salesCenter);
 }
Example #23
0
    public static bool UpdateSalesCenter(SalesCenter salesCenter)
    {
        SqlSalesCenterProvider sqlSalesCenterProvider = new SqlSalesCenterProvider();

        return(sqlSalesCenterProvider.UpdateSalesCenter(salesCenter));
    }
Example #24
0
    public int InsertSalesCenter(SalesCenter salesCenter)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("InsertSalesCenter", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@SalesCenterId", SqlDbType.Int).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@SalesCenterName", SqlDbType.NVarChar).Value = salesCenter.SalesCenterName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return (int)cmd.Parameters["@SalesCenterId"].Value;
        }
    }