Esempio n. 1
0
        protected void btnAddFooter_OnClick(object sender, ImageClickEventArgs e)
        {
            try
            {
                var desValue   = ((TextBox)gridFactor.FooterRow.Cells[1].Controls[1]).Text;
                var unitValue  = ((DropDownList)gridFactor.FooterRow.Cells[2].Controls[1]).SelectedValue;
                var countValue = ((TextBox)gridFactor.FooterRow.Cells[3].Controls[1]).Text;
                //var weightValue = ((TextBox)gridFactor.FooterRow.Cells[4].Controls[1]).Text;
                var priceValue = ((TextBox)gridFactor.FooterRow.Cells[5].Controls[1]).Text;

                var fd = new FactorDetail();

                fd.RowNumber   = ((List <FactorDetail>)Session["GridSource"]).Max(a => a.RowNumber) + 1;
                fd.Description = desValue;
                fd.GoodsUnitId = unitValue.ToSafeInt();
                fd.Count       = countValue.ToSafeDecimal();
                //fd.Weight = weightValue.ToSafeDecimal();
                fd.Price = priceValue.ToSafeDecimal();

                ((List <FactorDetail>)Session["GridSource"]).Add(fd);
                BindData();
            }
            catch (Exception ex)
            {
                Debuging.Error(ex, MethodBase.GetCurrentMethod().Name);
                ShowErrorMsg(MessageText.UNKNOWN_ERROR);
            }
        }
        public Message AddOrEdit(FactorDetail factorDetail)
        {
            var message = new Message();
            var ID      = factorDetail.FactorDetailId;
            int result  = _iFactorDetailRepository.AddOrEdit(factorDetail);

            try
            {
                if (result > 0)
                {
                    if (Convert.ToInt32(ID) > 0)
                    {
                        message = Message.SetMessages.SetSuccessMessage("Submission Updated Successfully!");
                    }
                    else
                    {
                        message = Message.SetMessages.SetSuccessMessage("Submission Successful!");
                    }
                }
                else
                {
                    message = Message.SetMessages.SetErrorMessage("Could not be submitted!");
                }
            }
            catch (Exception e)
            {
                message = Message.SetMessages.SetWarningMessage(e.Message.ToString());
            }

            return(message);
        }
Esempio n. 3
0
        //ثبت تمامی سفارشات
        private void submit_Click(object sender, EventArgs e)
        {
            if (dgvFactorDetails.Rows.Count == 0)
            {
                Service.ChangeForm(new Main(), this);
                return;
            }
            Factor factor = new Factor()
            {
                Date              = DateTime.Now,
                TotalPrice        = double.Parse(txtTotalPrice.Text.Replace(".", "").Replace("$", "")),
                TotalPriceWithTax = double.Parse(txtTotalPriceWithTax.Text.Replace(".", "").Replace("$", ""))
            };

            _factorService.Add(factor);
            foreach (DataGridViewRow current in dgvFactorDetails.Rows)
            {
                if (current.Cells[0].Value == null)
                {
                    continue;
                }
                var f = new FactorDetail()
                {
                    Count       = int.Parse(current.Cells[1].Value.ToString()),
                    Description = current.Cells[2].Value?.ToString() ?? "",
                    ProductId   = _productService.GetIdByName(current.Cells[0].Value.ToString()),
                    Factor      = factor,
                    TotalPrice  = double.Parse(current.Cells[4].Value.ToString())
                };
                _factorDetailService.Add(f);
            }
            _uow.SaveChanges();
            Service.ChangeForm(new Main(), this);
        }
        public ActionResult AddOrEdit(int id = 0)
        {
            FactorDetail factorDetail = new FactorDetail();

            if (id != 0)
            {
                factorDetail = _iFactorDetailManager.GetAFactorDetail(id);
            }
            return(View(factorDetail));
        }
Esempio n. 5
0
        public virtual ActionResult RegisterFactor()
        {
            List <RegisterOrderViewModel> ListOrder = TempData["ListOrder"] as List <RegisterOrderViewModel>;

            if (ListOrder == null)
            {
                return(RedirectToAction("Index", "OrderMe"));
            }
            bool success = false;

            try
            {
                var customer = db.Users
                               .Where(C => C.Name == User.Identity.Name)
                               .FirstOrDefault();
                Factor oFactor = new Factor();

                oFactor.Date          = DateTime.Now;
                oFactor.UserName      = User.Identity.Name;
                oFactor.FactorDetails = new List <FactorDetail>();
                oFactor.Mobile        = customer.Mobile;
                oFactor.Address       = customer.Address;
                oFactor.Description   = TempData["description"] as string;
                foreach (var item in ListOrder)
                {
                    FactorDetail oFactorDetail = new FactorDetail();
                    oFactorDetail.Name      = item.Name;
                    oFactorDetail.Price     = item.Price;
                    oFactorDetail.ProductId = item.Id;
                    oFactorDetail.FactorId  = oFactor.Id;
                    oFactorDetail.Count     = item.count;
                    oFactor.FactorDetails.Add(oFactorDetail);
                }

                db.Factors.Add(oFactor);
                db.SaveChanges();

                success = true;

                if (Request.Cookies["listProduct"] != null)
                {
                    Response.Cookies.Remove("listProduct");
                    Response.Cookies["listProduct"].Expires = DateTime.Now.AddDays(-1);
                    Session.Abandon();
                }
            }
            catch (Exception)
            {
                success = false;
            }

            ViewBag.success = success;

            return(View());
        }
Esempio n. 6
0
        public async static Task <IDTO> AddUpdate(FactorDetail factor)
        {
            string SPName  = "";
            string message = "";
            OracleDynamicParameters oracleParams = new OracleDynamicParameters();
            ComplateOperation <int> complate     = new ComplateOperation <int>();

            if (factor.ID.HasValue)
            {
                oracleParams.Add(FactorDetailSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ID ?? DBNull.Value);

                SPName  = FactorDetailSpName.SP_UPADTE_FACTOR_DETAIL;
                message = "Updated Successfully";
            }
            else
            {
                oracleParams.Add(FactorDetailSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Output);
                SPName  = FactorDetailSpName.SP_INSERT_FACTOR_DETAIL;
                message = "Inserted Successfully";
            }


            oracleParams.Add(FactorDetailSpParams.PARAMETER_NAME, OracleDbType.Varchar2, ParameterDirection.Input, (object)factor.Name ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_NAME2, OracleDbType.Varchar2, ParameterDirection.Input, (object)factor.Name2 ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_DIC_COL_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.DictionaryID ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ENTRY_TYPE, OracleDbType.Int64, ParameterDirection.Input, (object)factor.EntryType ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_PRD_FACT_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.FactorID ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_FROM_VALUE, OracleDbType.Int64, ParameterDirection.Input, (object)factor.FromValue ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_TO_VALUE, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ToValue ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_F_FROM_DATE, OracleDbType.Date, ParameterDirection.Input, (object)factor.FromDate ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_F_TO_DATE, OracleDbType.Date, ParameterDirection.Input, (object)factor.ToDate ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_CHG_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ChargeID ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_PRD_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ProductID ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_PRDT_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ProductDetailID ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_FRRMULA_EDOTORS, OracleDbType.Varchar2, ParameterDirection.Input, (object)factor.FrrmulaEdotors ?? DBNull.Value);
            oracleParams.Add(FactorDetailSpParams.PARAMETER_ST_PRD_FACD_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ProductFacdID ?? DBNull.Value);



            if (await NonQueryExecuter.ExecuteNonQueryAsync(SPName, oracleParams) == -1)
            {
                complate.message = "Operation Success";
            }

            else
            {
                complate.message = "Operation Failed";
            }

            return(complate);
        }
Esempio n. 7
0
        public async static Task <IDTO> DeleteFactorDetail(FactorDetail factor)
        {
            OracleDynamicParameters oracleParams = new OracleDynamicParameters();
            ComplateOperation <int> complate     = new ComplateOperation <int>();
            var dyParam = new OracleDynamicParameters();

            dyParam.Add(FactorDetailSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Input, (object)factor.ID ?? DBNull.Value);
            if (await NonQueryExecuter.ExecuteNonQueryAsync(FactorDetailSpName.SP_DELETE_FACTOR_DETAIL, dyParam) == -1)
            {
                complate.message = "Operation Successed";
            }
            else
            {
                complate.message = "Operation Failed";
            }
            return(complate);
        }
        public int AddOrEdit(FactorDetail factorDetail)
        {
            if (factorDetail.FactorDetailId == 0)
            {
                factorDetail.CreatedDate = DateTime.Now;
                factorDetail.UpdatedDate = DateTime.Now;
                factorDetail.CreatedBy   = 1;
                factorDetail.UpdatedBy   = 1;
                _dbContext.FactorDetails.Add(factorDetail);
            }
            else
            {
                factorDetail.UpdatedBy               = 1;
                factorDetail.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(factorDetail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Esempio n. 9
0
        protected void btnAddFirstRow_OnClick(object sender, ImageClickEventArgs e)
        {
            try
            {
                var newRow = new FactorDetail();
                newRow.RowNumber = 1;
                var source = new List <FactorDetail>();
                source.Add(newRow);

                Session["GridSource"] = source;

                gridFactor.EditIndex = 0;
                BindData();
                //((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[1].Controls[1]).Focus();
                //BindFooterGoodsUnitDrp();
            }
            catch (Exception ex)
            {
                Debuging.Error(ex, MethodBase.GetCurrentMethod().Name);
                ShowErrorMsg(MessageText.UNKNOWN_ERROR);
            }
        }
 public void Remove(FactorDetail fd)
 {
     _factorDetails.Remove(fd);
 }
 public void Add(FactorDetail fd)
 {
     _factorDetails.Add(fd);
 }
        public ActionResult AddOrEdit(FactorDetail factorDetail)
        {
            var data = _iFactorDetailManager.AddOrEdit(factorDetail);

            return(Json(new { messageType = data.MessageType, message = data.ReturnMessage, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", _iFactorDetailManager.GetAllFactorDetail()) }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 14
0
 public ActionResult Sale(SaleViweModel sale, int id)
 {
     if (ModelState.IsValid)
     {
         var user = db.Users.FirstOrDefault(u => u.Mobile == User.Identity.Name);
         if (user != null)
         {
             string strtoday = pc.GetYear(DateTime.Now).ToString("0000") + "/" +
                               pc.GetMonth(DateTime.Now).ToString("00") + "/" +
                               pc.GetDayOfMonth(DateTime.Now).ToString("00");
             var factor = db.Factors.FirstOrDefault(f => f.UserId == user.Id && f.IsPay == false);
             if (factor != null)
             {
                 var det = db.FactorDetails.FirstOrDefault(d => d.factorId == factor.Id && d.ProdcutId == id);
                 if (det != null)
                 {
                     det.Tedad = det.Tedad + sale.SaleCount;
                     db.SaveChanges();
                 }
                 else
                 {
                     FactorDetail newdetail = new FactorDetail()
                     {
                         factorId  = factor.Id,
                         ProdcutId = id,
                         Tedad     = sale.SaleCount
                     };
                     db.FactorDetails.Add(newdetail);
                     db.SaveChanges();
                 }
             }
             else
             {
                 Factor newfactor = new Factor()
                 {
                     UserId        = user.Id,
                     IsPay         = false,
                     DateFactor    = strtoday,
                     CutPrice      = 0,
                     NumberFactor  = "",
                     SumItem       = 0,
                     Tax           = 0,
                     SumPrice      = 0,
                     NumberControl = "",
                     DatePay       = "",
                 };
                 db.Factors.Add(newfactor);
                 db.SaveChanges();
                 FactorDetail newdetail = new FactorDetail()
                 {
                     factorId  = db.Factors.Max(f => f.Id),
                     ProdcutId = id,
                     Tedad     = sale.SaleCount
                 };
                 db.FactorDetails.Add(newdetail);
                 db.SaveChanges();
             }
             return(RedirectToAction("ShopingCart"));
         }
         else
         {
             return(RedirectToAction("Login", "Account"));
         }
     }
     return(PartialView());
 }
Esempio n. 15
0
        public ActionResult AddToShoppingCart(ShoppingCartViewModel shoppingCart, int id)
        {
            var user    = db.Users.FirstOrDefault(u => u.Mobile == User.Identity.Name);
            var product = db.Products.Find(id);
            var factor  = db.Factors.FirstOrDefault(f => f.UserId == user.Id && f.IsPay == false);

            if (factor != null)
            {
                var detail = db.FactorDetail.FirstOrDefault(d => d.FactorId == factor.Id && d.ProductId == id);
                if (detail != null)
                {
                    detail.Count       = shoppingCart.DetailCount + detail.Count;
                    detail.DetailPrice = product.Price;
                    db.SaveChanges();
                }
                else
                {
                    FactorDetail factorDetail = new FactorDetail()
                    {
                        FactorId    = factor.Id,
                        ProductId   = id,
                        Count       = shoppingCart.DetailCount,
                        DetailPrice = product.Price
                    };
                    db.FactorDetail.Add(factorDetail);
                    db.SaveChanges();
                }
            }
            else
            {
                Random random = new Random();
                string str    = random.Next(100000, 999999).ToString();

                var address   = db.Addresses.FirstOrDefault(a => a.UserId == user.Id);
                int addressId = 0;
                if (address != null)
                {
                    addressId = address.Id;
                }

                Factor newfactor = new Factor()
                {
                    UserId    = user.Id,
                    Date      = "",
                    PayDate   = "",
                    IsPay     = false,
                    Number    = str,
                    PayNumber = "",
                    PayTime   = "",
                    Price     = 0,
                    AddressId = addressId
                };
                db.Factors.Add(newfactor);
                db.SaveChanges();
                FactorDetail factorDetail = new FactorDetail()
                {
                    FactorId    = newfactor.Id,
                    ProductId   = id,
                    Count       = shoppingCart.DetailCount,
                    DetailPrice = product.Price
                };
                db.FactorDetail.Add(factorDetail);
                db.SaveChanges();
            }
            return(Redirect("/product/" + id + "/" + product.Name));
        }