Esempio n. 1
0
 public ProductController(CCContext ccContext)
 {
     _productBl = new ProductBl(ccContext);
 }
Esempio n. 2
0
 public HomeController(SportWorldContext SportWorldContext)
 {
     _productBl = new ProductBl(SportWorldContext);
 }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool   blValidateName = false;
                bool   blValidateCode = false;
                string strProductName = txtProductName.Text.Trim();
                string strCode        = txtIdentifierCode.Text.Trim();
                if (ViewState["Mode"].ToString() == "Save")
                {
                    blValidateName = ValidateName(strProductName, -1);
                    blValidateCode = ValidateIdentifierCode(strCode, -1);
                }
                else
                {
                    blValidateName = ValidateName(strProductName, Convert.ToInt32(ViewState["ProductID"].ToString()));
                    blValidateCode = ValidateIdentifierCode(strCode, Convert.ToInt32(ViewState["ProductID"].ToString()));
                }

                if (blValidateCode == false)
                {
                    if (blValidateName == false)
                    {
                        ProductBo objProductBo = new ProductBo();
                        ProductBl objProductBl = new ProductBl();

                        objProductBo.ProductName    = txtProductName.Text.Trim();
                        objProductBo.IdentifierCode = Convert.ToInt32(txtIdentifierCode.Text);

                        if (ViewState["Mode"].ToString() == "Save")
                        {
                            objProductBo.CreatedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]);
                            objProductBo.CreatedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                            objProductBo.IsDeleted   = 0;

                            var objResult = objProductBl.Product_Insert(objProductBo);
                            if (objResult != null)
                            {
                                if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                                {
                                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Saved Successfully.');</script>");
                                    ClearAll();
                                    BindProduct();
                                    PanelVisibilityMode(true, false);
                                }
                            }
                        }
                        else if (ViewState["Mode"].ToString() == "Edit")
                        {
                            objProductBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.Userid]).ToString();
                            objProductBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                            objProductBo.ProductId        = Convert.ToInt32(ViewState["ProductID"].ToString());

                            var objResult = objProductBl.Product_Update(objProductBo);

                            if (objResult != null)
                            {
                                if (objResult.Status == ApplicationResult.CommonStatusType.Success)
                                {
                                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Updated Successfully.');</script>");
                                    ClearAll();
                                    BindProduct();
                                    PanelVisibilityMode(true, false);
                                }
                            }
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('ProductName Already Exist.Please Check it.');</script>");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('IdentifierCode Already Exist.Please Check it.');</script>");
                }
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
            }
        }