protected void btnSaveManufacturer_ServerClick(object sender, EventArgs e)
        {
            ManufacturerObject obj = new ManufacturerObject();

            obj.Manufacturer_Name = txtManufacturerName.Value;

            ManageManufacturer manufacturerObj = new ManageManufacturer();

            bool success = manufacturerObj.insert(obj, ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString);

            if (success)
            {
                divSuccess.Visible = true;
            }
            else
                divFailure.Visible = true;
        }
        protected void btnSaveManufacturer_ServerClick(object sender, EventArgs e)
        {
            ManufacturerObject obj = new ManufacturerObject();

            obj.Manufacturer_Name = txtManufacturerName.Value;

            ManageManufacturer manufacturerObj = new ManageManufacturer();

            bool success = manufacturerObj.updateAManufacturer(ConfigurationManager.ConnectionStrings["MVSSqlDev2008ConnectionString"].ConnectionString, obj, Convert.ToInt32(Session["rowIndex"]));

            if (success)
            {
                divSuccess.Visible = true;
            }
            else
                divFailure.Visible = true;

            Session.Remove("rowIndex");
        }
        public List<SqlParameter> insertParameters(ManufacturerObject manufacturerObj)
        {
            List<SqlParameter> insertParamsArray = new List<SqlParameter>();

            insertParamsArray.Add(new SqlParameter("@Manufacturer_Name", manufacturerObj.Manufacturer_Name));

            return insertParamsArray;
        }
        public Boolean updateAManufacturer(string connectionString, ManufacturerObject manufacturerObj, int rowIndex)
        {
            try
            {
                conn = DBUtility.createConnection(connectionString);
                SqlCommand cmdIns = DBUtility.PrepareSPCommand("sp_UpdateManufacturer", insertParameters(manufacturerObj), conn);
                cmdIns.Parameters.Add(new SqlParameter("@Manufacturer_ID", rowIndex));

                int rowsUpdated = cmdIns.ExecuteNonQuery();

                cmdIns.Dispose();
                DBUtility.Close(conn);
                conn.Dispose();

                if (rowsUpdated > 0)
                {
                    return true;
                }
                else return false;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString(), ex);
            }
            finally
            {
                DBUtility.Close(conn);
                conn.Dispose();
            }
        }
        public bool insert(ManufacturerObject manufacturerObj, string connectionString)
        {
            try
            {
                conn = DBUtility.createConnection(connectionString);
                SqlCommand cmdIns = DBUtility.PrepareSPCommand("sp_InsertManufacturer", insertParameters(manufacturerObj), conn);

                int rowsUpdated = cmdIns.ExecuteNonQuery();

                //    cmdIns.Parameters.Clear();
                //    cmdIns.CommandText = "SELECT @@IDENTITY";

                //    // Get the last inserted id.
                //    int insertID = Convert.ToInt32(cmdIns.ExecuteScalar());

                cmdIns.Dispose();
                DBUtility.Close(conn);
                conn.Dispose();
                if (rowsUpdated > 0)
                {
                    return true;
                }
                else return false;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString(), ex);
            }
            finally
            {
                DBUtility.Close(conn);
                conn.Dispose();
            }
        }