public mProduct fGetIns(mProduct pPrd) { try { var vPrd = (from p in Db.tbl_product where p.product_id == pPrd.product_id select new mProduct { product_id = p.product_id, product_img1 = p.product_img1, product_img2 = p.product_img2, product_img_alt = p.product_img_alt, product_price = p.product_price, product_summery = p.product_summery, product_title1 = p.product_title1, product_title2 = p.product_title2, product_cat = p.product_cat, product_parent = p.product_parent, product_exist = p.product_exist, product_exp = p.product_exp, product_visit = p.product_visit }).FirstOrDefault(); return(vPrd); } catch (Exception) { return(null); } }
public bool InsertIns(mProduct pPrd) { try { tbl_product vPrd = new tbl_product(); var query = from b in Db.tbl_product orderby b.product_id descending select b; vPrd = query.FirstOrDefault(); tbl_product p = new tbl_product(); Random rnd = new Random(); p.product_img1 = pPrd.product_img1; p.product_img2 = pPrd.product_img2; p.product_img_alt = pPrd.product_img_alt; p.product_price = pPrd.product_price; p.product_summery = pPrd.product_summery; p.product_title1 = pPrd.product_title1; p.product_title2 = pPrd.product_title2; p.product_cat = pPrd.product_cat; p.product_parent = pPrd.product_parent; p.product_exist = pPrd.product_exist; p.product_exp = pPrd.product_exp; p.product_save = pPrd.product_save; p.product_visit = 200; p.product_id = vPrd.product_id + 1; Db.tbl_product.Add(p); return(Convert.ToBoolean(Db.SaveChanges())); } catch (Exception) { return(false); } }
protected void btnSubmit_OnClick(object sender, EventArgs e) { try { string state; CustomProfile profile = CustomProfile.GetProfile(); //if (checkduplicate() == "") //{ iProductMasterClient productClient = new iProductMasterClient(); mProduct obj = new mProduct(); state = "Edit"; obj = productClient.GetmProductToUpdate(Convert.ToInt64(hdnprodID.Value), profile.DBConnection._constr); obj.LastModifiedBy = profile.Personal.UserID.ToString(); obj.LastModifiedDate = DateTime.Now; obj.ProductTypeID = Convert.ToInt64(ddlProductType.SelectedItem.Value); obj.ProductCategoryID = Convert.ToInt64(ddlCategory.SelectedItem.Value); if (ddlSubCategory.SelectedIndex > 0) { obj.ProductSubCategoryID = Convert.ToInt64(ddlSubCategory.SelectedItem.Value); } obj.ProductCode = txtProductCode.Text.ToString().Trim(); obj.Name = txtProductName.Text.ToString().Trim(); obj.UOMID = Convert.ToInt64(ddlUOM.SelectedItem.Value); if (txtPrincipalPrice.Text == "") { txtPrincipalPrice.Text = "0"; } obj.PrincipalPrice = Convert.ToDecimal(txtPrincipalPrice.Text); obj.Description = txtPrdDesc.Text.ToString().Trim(); obj.Installable = Convert.ToBoolean(0); hdnprodID.Value = productClient.FinalSaveProductDetailByProductID(obj, profile.DBConnection._constr).ToString(); productClient.Close(); GetIssueHead(); this.ModelPopUp.Hide(); //} } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "PartIssueEntry", "ProductSave"); } finally { } }
public ActionResult InsuranceGet(int pId = 0) { if (fUserControl() == 0) { ViewBag.Message = "شما وارد سایت نشده اید..."; return(RedirectToAction("LoginForm", "Login")); } mProduct vProduct = new mProduct(); if (pId > 0) { vProduct.product_id = pId; vProduct = p.fGetIns(vProduct); } else { vProduct = new mProduct(); } return(View("_Insurance", vProduct)); }
public bool fUpdateIns(mProduct pPrd) { tbl_product p = new tbl_product(); p.product_id = pPrd.product_id; p.product_img1 = pPrd.product_img1; p.product_img2 = pPrd.product_img2; p.product_img_alt = pPrd.product_img_alt; p.product_price = pPrd.product_price; p.product_summery = pPrd.product_summery; p.product_title1 = pPrd.product_title1; p.product_title2 = pPrd.product_title2; p.product_cat = pPrd.product_cat; p.product_parent = pPrd.product_parent; p.product_exist = pPrd.product_exist; p.product_exp = pPrd.product_exp; p.product_save = pPrd.product_save; Db.tbl_product.Attach(p); Db.Entry(p).State = System.Data.Entity.EntityState.Modified; return(Convert.ToBoolean(Db.SaveChanges())); }
public ActionResult Insurance(int page) { mHome vHome = new mHome(); mLink vLink = new mLink(); vLink.link_status = 6; vLink.link_cat = page; mProduct vProduct = new mProduct(); List <mArticle> aArticle = new List <mArticle>(); mArticle vArticle = new mArticle(); List <mLink> aLinks = new List <mLink>(); aLinks = l.fLinkList(12, 0, vLink); if (aLinks != null && aLinks.Count > 0) { vHome.aLink = aLinks; } else { vHome.aLink = new List <mLink>(); } vArticle.article_type = 1; aArticle = a.fArticlesListMostVisited(10, 0, vArticle, vHome); if (aArticle != null && aArticle.Count > 0) { vHome.aArticles = aArticle; } else { vHome.aArticles = new List <mArticle>(); } vProduct.product_id = page; vHome.Ins = p.fGetInsCat(vProduct); if (vHome == null) { vHome = new mHome(); } return(View(vHome)); }
public ActionResult InsurancePost(mProduct pInsurance) { if (fUserControl() == 0) { ViewBag.Message = "شما وارد سایت نشده اید..."; return(RedirectToAction("LoginForm", "Login")); } if (!(ModelState.IsValid)) { ViewBag.error = "خطا در اطلاعات ورودی !"; return(View(pInsurance)); } else { if (pInsurance.img_file1 != null && pInsurance.img_file1.ContentLength > 0) { if (pInsurance.img_file1.ContentLength < 10485760) { Random rnd = new Random(); string img = rnd.Next().ToString() + ".jpg"; string Path = System.IO.Path.Combine(Server.MapPath("~/images/Product/")); pInsurance.img_file1.SaveAs(Path + img); using (MemoryStream ms = new MemoryStream()) { pInsurance.img_file1.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); pInsurance.product_img1 = img; } } else { ViewBag.error = "حد اکثر اندازه فایل را رعایت نکرده اید !"; return(View(pInsurance)); } } if (pInsurance.img_file2 != null && pInsurance.img_file2.ContentLength > 0) { if (pInsurance.img_file2.ContentLength < 10485760) { Random rnd = new Random(); string img = rnd.Next().ToString() + ".jpg"; string Path = System.IO.Path.Combine(Server.MapPath("~/images/Insurance/")); pInsurance.img_file2.SaveAs(Path + img); using (MemoryStream ms = new MemoryStream()) { pInsurance.img_file2.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); pInsurance.product_img1 = img; } } else { ViewBag.error = "حد اکثر اندازه فایل را رعایت نکرده اید !"; return(View(pInsurance)); } } if (pInsurance.product_id > 0) { if (p.fUpdateIns(pInsurance)) { return(RedirectToAction("index")); } ViewBag.error = "خطا در انجام عملیات ! "; } else { if (p.InsertIns(pInsurance)) { return(RedirectToAction("index")); } ViewBag.error = "خطا در انجام عملیات ! "; } } return(View(pInsurance)); }
protected void FinalSaveProductDetailByProductID() { try { string state; CustomProfile profile = CustomProfile.GetProfile(); if (checkDuplicate() == "") { iProductMasterClient productClient = new iProductMasterClient(); mProduct obj = new mProduct(); if (hdnprodID.Value != "0") { state = "Edit"; obj = productClient.GetmProductToUpdate(Convert.ToInt64(hdnprodID.Value), profile.DBConnection._constr); obj.LastModifiedBy = profile.Personal.UserID.ToString(); obj.LastModifiedDate = DateTime.Now; } else { state = "AddNew"; obj.CreatedBy = profile.Personal.UserID.ToString(); obj.CreationDate = DateTime.Now; } obj.ProductTypeID = Convert.ToInt64(ddlProductType.SelectedItem.Value); obj.ProductCategoryID = Convert.ToInt64(ddlCategory.SelectedItem.Value); if (ddlSubCategory.SelectedIndex > 0) { obj.ProductSubCategoryID = Convert.ToInt64(ddlSubCategory.SelectedItem.Value); } obj.ProductCode = txtProductCode.Text.ToString().Trim(); obj.Name = txtProductName.Text.ToString().Trim(); obj.UOMID = Convert.ToInt64(ddlUOM.SelectedItem.Value); if (txtPrincipalPrice.Text == "") { txtPrincipalPrice.Text = "0"; } obj.PrincipalPrice = Convert.ToDecimal(txtPrincipalPrice.Text); if (txtFixedDisc.Text == "") { txtFixedDisc.Text = "0"; } obj.FixedDiscount = Convert.ToDecimal(txtFixedDisc.Text); obj.FixedDiscountPercent = chkboxFixedDiscIsPercent.Checked; obj.Installable = chkProductSpe.Items[0].Selected; obj.AMC = chkProductSpe.Items[1].Selected; if (txtWarrenyInDays.Text == "") { txtWarrenyInDays.Text = "0"; } obj.WarrantyDays = Convert.ToInt32(txtWarrenyInDays.Text); if (txtGuaranteeInDays.Text == "") { txtGuaranteeInDays.Text = "0"; } obj.GuaranteeDays = Convert.ToInt32(txtGuaranteeInDays.Text); obj.Active = "N"; if (rbtYes.Checked == true) { obj.Active = "Y"; } hdnprodID.Value = productClient.FinalSaveProductDetailByProductID(obj, profile.DBConnection._constr).ToString(); productClient.FinalSaveProductTaxDetailByProductID(Session.SessionID, profile.Personal.UserID.ToString(), Convert.ToInt64(hdnprodID.Value), profile.DBConnection._constr); productClient.FinalSaveProductImagesByProductID(Session.SessionID.ToString(), profile.Personal.UserID.ToString(), Convert.ToInt64(hdnprodID.Value), Server.MapPath(""), profile.DBConnection._constr); productClient.FinalSaveProductSpecificationDetailByProductID(sessionID, profile.Personal.UserID.ToString(), Convert.ToInt64(hdnprodID.Value), Convert.ToInt64(profile.Personal.CompanyID), profile.DBConnection._constr); productClient.FinalSaveProductInventory(sessionID, CurrentObject, Convert.ToInt64(hdnprodID.Value), Convert.ToDateTime(UC_EffectiveDateInventory.Date), profile.Personal.UserID.ToString(), profile.DBConnection._constr); UC_AttachDocument1.FinalSaveDocument(Convert.ToInt64(hdnprodID.Value)); productClient.Close(); if (hdnprodID.Value != "0") { WebMsgBox.MsgBox.Show("Record saved sussessfully"); } // clear(); GetProductDocumentByProductID(); GetProductSpecificationDetailByProductID(); GetProductTaxDetailByProductID(); GetProductImagesByProductID(); GetProductList(); GVRateHistory(); FillInventoryGrid(); setActiveTab(1); clear(); // changePrice1.Attributes.Add("style", "visibility:visible"); } } catch (System.Exception ex) { Login.Profile.ErrorHandling(ex, this, "Product master", "pageSave"); } finally { } }