Ejemplo n.º 1
0
        private void Parameters(string Action, int FabricId)
        {
            try
            {
                if (txtFabricName.Text != "")
                {
                    clsFabric objFabric = new clsFabric();
                    DataSet   ds        = new DataSet();
                    objFabric.Action      = Action;
                    objFabric.FabricId    = FabricId;
                    objFabric.FabricName  = txtFabricName.Text;
                    objFabric.Description = txtDescription.Text;
                    objFabric.CategoryId  = Convert.ToInt32(ddlCategory.SelectedItem.Value);
                    objFabric.ImagePath   = "";
                    if (FileUpload1.HasFile)
                    {
                        var            _with1     = HttpContext.Current;
                        string         strPath    = _with1.Server.MapPath("../../Fabric/");
                        HttpPostedFile postedFile = FileUpload1.PostedFile;
                        string         filename   = postedFile.FileName;
                        string         fileExt1   = System.IO.Path.GetExtension(filename).Replace(".", "");
                        fileExt1 = System.IO.Path.GetExtension(filename).Replace(".", "");
                        filename = filename.Replace("." + fileExt1, "");
                        filename = filename + "1" + string.Format("{0:MMddyyyyhhmmssfffffftt}", DateTime.Now) + "." + fileExt1.ToString();
                        postedFile.SaveAs(strPath + filename);

                        objFabric.ImagePath = filename;
                    }


                    ds = objFabric.fnFabric();
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        divAlert.Visible   = true;
                        divAlert.InnerHtml = ds.Tables[0].Rows[0]["MSG"].ToString();
                    }
                    else
                    {
                        divAlert.Visible   = true;
                        divAlert.InnerHtml = "Something went wrong";
                    }
                    fillGrid();
                    clear();
                }
                else
                {
                    divAlert.Visible   = true;
                    divAlert.InnerHtml = "Enter all required fileds";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void fillGrid()
        {
            try
            {
                clsFabric objFabric = new clsFabric();
                DataSet   ds        = new DataSet();
                objFabric.Action = "SELECT";
                ds = objFabric.fnFabric();
                gvFabric.DataSource = ds;
                gvFabric.DataBind();
                ViewState["dt"] = ds.Tables[0];

                ddlCategory.DataTextField  = "CategoryName";
                ddlCategory.DataValueField = "CategoryId";
                ddlCategory.DataSource     = ds.Tables[1];
                ddlCategory.DataBind();
            }
            catch (Exception ex)
            { }
        }