public Int64 Update(unitMaster objcategory)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "unit_Update";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@id";
                param.Value         = objcategory.id;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@unitname", objcategory.unitname);

                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
Beispiel #2
0
    public void BindColor(Int64 CategoryId)
    {
        unitMaster objcategory = (new Cls_unit_b().SelectById(CategoryId));

        if (objcategory != null)
        {
            //ddlBank.SelectedValue = objcategory.bankid.ToString();
            txtunitname.Text = objcategory.unitname;
        }
    }
        public unitMaster SelectById(Int64 id)
        {
            SqlDataAdapter da;
            DataSet        ds          = new DataSet();
            unitMaster     objcategory = new unitMaster();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "unit_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@id", id);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    objcategory.id       = Convert.ToInt64(ds.Tables[0].Rows[0]["id"]);
                                    objcategory.unitname = Convert.ToString(ds.Tables[0].Rows[0]["unitname"]);
                                    //objcategory.imagename = Convert.ToString(ds.Tables[0].Rows[0]["imagename"]);
                                    //objcategory.actualprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["actualprice"]);
                                    //objcategory.discountprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["discountprice"]);
                                    //objcategory.shortdesc = Convert.ToString(ds.Tables[0].Rows[0]["shortdesc"]);
                                    //objcategory.longdescp = Convert.ToString(ds.Tables[0].Rows[0]["longdescp"]);
                                    //objcategory.bankid = Convert.ToInt32(ds.Tables[0].Rows[0]["bankid"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objcategory);
        }
Beispiel #4
0
        public IActionResult unitMaster([FromBody] unitMaster obj)

        {
            obj.isActive = true;
            if (obj.unitId != 0)
            {
                _context.unitMasters.Attach(obj);
                _context.unitMasters.Update(obj);
            }
            else
            {
                _context.unitMasters.Add(obj);
            }
            _context.SaveChanges();
            return(new ObjectResult("Unit Added Successfully"));
        }
Beispiel #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64      Result      = 0;
        unitMaster objcategory = new unitMaster();

        objcategory.unitname = txtunitname.Text.Trim();

        if (Request.QueryString["id"] != null)
        {
            objcategory.id = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result         = (new Cls_unit_b().Update(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageUnit.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Color Not Updated";
                BindColor(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_unit_b().Insert(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageUnit.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Color Not Inserted";
            }
        }
    }