public void DeleteItemMaster(string ColorName)
 {
     try
     {
         var ColorMaster = new ColorMaster
         {
             ColorCode     = ColorCode,
             ColorName     = ColorName,
             OperationType = 3
         };
         int DeleteStatus = _instanceRepository.InsertUpdateDeleteColorMaster(ColorMaster);
         if (DeleteStatus >= 1)
         {
             messageShow.singlemsgtext("Deleted Successfully");
         }
         else if (DeleteStatus == -1)
         {
             messageShow.singlemsgtext("Can not delete the color, because the color has transactions!");
         }
         else
         {
             messageShow.singlemsgtext("Unable to Delete");
         }
         ResetControlles();
         GetColorMasterList("");
     }
     catch (Exception _exception)
     {
         CmC.InsertException(_exception);
         messageShow.singlemsgtext(CmC.ExceptionErrorMessage);
     }
 }
示例#2
0
        public async System.Threading.Tasks.Task <ActionResult> UpdateColorMaster(ColorMaster _color)
        {
            List <string> res         = new List <string>();
            var           currentuser = Commonhelper.GetCurrentUserDetails();

            try
            {
                ColorMaster master = new ColorMaster();
                master.Id            = _color.Id;
                master.ModifiedBy    = currentuser.Id;
                master.ModifiedDate  = DateTime.Now;
                master.Name          = _color.Name;
                master.Description   = _color.Description;
                master.StoreId       = currentuser.StoreId;
                master.workstation   = Commonhelper.GetStation();
                master.FinancialYear = DateTime.Now.Year;
                master.CompanyId     = currentuser.CompanyId;
                try
                {
                    Commonhelper.Updatecolor(master);
                    return(RedirectToAction("ColorMaster"));
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("ColorMaster"));
                }
            }
            catch (Exception ex)
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('Error in category creation!');</script>"));
            }
        }
        public Int64 Update(ColorMaster objcategory)
        {
            Int64 result = 0;

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

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

                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);
        }
示例#4
0
        public async Task <IHttpActionResult> PutColorMaster(int id, ColorMaster colorMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != colorMaster.Id)
            {
                return(BadRequest());
            }

            db.Entry(colorMaster).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ColorMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#5
0
        public async System.Threading.Tasks.Task <ActionResult> EditColor(string Id)
        {
            ColorMaster _master = new ColorMaster();

            _master = Commonhelper.GetColorById(Id);
            return(View(_master));
        }
        /// <summary>
        /// Insert/update/delete the color master details..
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        public int InsertUpdateDeleteColorMaster(ColorMaster ColorMaster)
        {
            int LastId    = 0;
            var DbManager = new DBManager("DBConnection");

            DbManager.Insert(_StoredProcedures.InsertUpdateDeleteColorMaster_SP, CommandType.StoredProcedure, _AdminMasterIRepository.AddParametersColorMasterInsert(ColorMaster), out LastId);
            return(LastId);
        }
 /// <summary>
 /// Add parameters while adding the product details
 /// </summary>
 /// <param name="users"></param>
 /// <returns></returns>
 public IDbDataParameter[] AddParametersColorMasterInsert(ColorMaster ColorMaster)
 {
     parameters.Clear();
     parameters.Add(dbManager.CreateParameter("@ColorName", 50, ColorMaster.ColorName, DbType.String));
     parameters.Add(dbManager.CreateParameter("@ColorCode", 7, ColorMaster.ColorCode, DbType.Int32));
     parameters.Add(dbManager.CreateParameter("@OperationType", 2, ColorMaster.OperationType, DbType.Int16));
     return(parameters.ToArray());
 }
示例#8
0
    public void BindColor(Int64 CategoryId)
    {
        ColorMaster objcategory = (new Cls_color_b().SelectById(CategoryId));

        if (objcategory != null)
        {
            //ddlBank.SelectedValue = objcategory.bankid.ToString();
            txtColorName.Text = objcategory.colorname;
        }
    }
示例#9
0
        public async Task <IHttpActionResult> GetColorMaster(int id)
        {
            ColorMaster colorMaster = await db.ColorMasters.FindAsync(id);

            if (colorMaster == null)
            {
                return(NotFound());
            }

            return(Ok(colorMaster));
        }
示例#10
0
        public async Task <IHttpActionResult> PostColorMaster(ColorMaster colorMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ColorMasters.Add(colorMaster);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = colorMaster.Id }, colorMaster));
        }
        public ColorMaster SelectById(Int64 cid)
        {
            SqlDataAdapter da;
            DataSet        ds          = new DataSet();
            ColorMaster    objcategory = new ColorMaster();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "color_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@cid", cid);
                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.cid       = Convert.ToInt64(ds.Tables[0].Rows[0]["cid"]);
                                    objcategory.colorname = Convert.ToString(ds.Tables[0].Rows[0]["colorname"]);
                                    //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);
        }
示例#12
0
        public async Task <IHttpActionResult> DeleteColorMaster(int id)
        {
            ColorMaster colorMaster = await db.ColorMasters.FindAsync(id);

            if (colorMaster == null)
            {
                return(NotFound());
            }

            db.ColorMasters.Remove(colorMaster);
            await db.SaveChangesAsync();

            return(Ok(colorMaster));
        }
示例#13
0
        public async System.Threading.Tasks.Task <ActionResult> CreateColorMaster(ColorMaster _master)
        {
            List <string> res         = new List <string>();
            var           currentuser = Commonhelper.GetCurrentUserDetails();

            if (ModelState.IsValid)
            {
                try
                {
                    ColorMaster master = new ColorMaster();
                    master.Id            = Guid.NewGuid().ToString();
                    master.CreatedBy     = currentuser.Id;
                    master.CreatedDate   = DateTime.Now;
                    master.Name          = _master.Name;
                    master.Description   = _master.Description;
                    master.StoreId       = currentuser.StoreId;
                    master.workstation   = Commonhelper.GetStation();
                    master.FinancialYear = DateTime.Now.Year;
                    master.CompanyId     = currentuser.CompanyId;
                    master.Isactive      = true;
                    try
                    {
                        Commonhelper.SaveColor(master);
                        return(RedirectToAction("ColorMaster"));
                    }
                    catch (Exception ex)
                    {
                        return(RedirectToAction("ColorMaster"));
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("ColorMaster"));
                }
            }
            else
            {
            }

            return(Json(res));
        }
示例#14
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64       Result      = 0;
        ColorMaster objcategory = new ColorMaster();

        objcategory.colorname = txtColorName.Text.Trim();

        if (Request.QueryString["id"] != null)
        {
            objcategory.cid = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result          = (new Cls_color_b().Update(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageColor.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_color_b().Insert(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageColor.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Color Not Inserted";
            }
        }
    }
 private void GetColorMasterList(string SearchText)
 {
     try
     {
         var ColorMaster = new ColorMaster
         {
             ColorName     = SearchText,
             OperationType = 1
         };
         dt.Clear();
         DataGridColorMaster.Refresh();
         dt = CmC.GetColorMasterList(SearchText);
         SBind.DataSource = dt;
         datagriddesign();
         DataGridColorMaster.DataSource = SBind;
     }
     catch (Exception _exception)
     {
         CmC.InsertException(_exception);
         messageShow.singlemsgtext(CmC.ExceptionErrorMessage);
     }
 }
 private void BtnInsertUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(TxtColorName.Text.ToString()))
         {
             messageShow.singlemsgtext("Color Name should not be empty.");
             TxtColorName.Focus();
             return;
         }
         var ColorMaster = new ColorMaster
         {
             ColorName     = TxtColorName.Text.ToString(),
             ColorCode     = ColorCode,
             OperationType = BtnInsertUpdate.Text.ToString() == "Save" ? 1 : 2
         };
         int id = _instanceRepository.InsertUpdateDeleteColorMaster(ColorMaster);
         if (id >= 1)
         {
             messageShow.singlemsgtext(ColorMaster.OperationType == 1 ? "New Color added successfully" : "Color updated successfully");
             ColorMaster.ColorName = "";
             ResetControlles();
         }
         else if (id == -1)
         {
             messageShow.singlemsgtext("The color name already exists, please try another name!");
         }
         else
         {
             messageShow.singlemsgtext("Error in color insert/update");
         }
     }
     catch (Exception _exception)
     {
         CmC.InsertException(_exception);
         messageShow.singlemsgtext(CmC.ExceptionErrorMessage);
     }
 }
示例#17
0
        public ActionResult DeleteColor(ColorMaster cat)
        {
            ColorMaster cm = new ColorMaster();

            try
            {
                using (var ctx = new ApplicationDbContext())
                {
                    cm = ctx.ColorMaster.Where(x => x.Id == cat.Id).FirstOrDefault();
                    if (cm != null)
                    {
                        cm.Isactive         = false;
                        ctx.Entry(cm).State = System.Data.Entity.EntityState.Modified;
                        ctx.SaveChanges();
                        return(RedirectToAction("ColorMaster"));
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("ColorMaster"));
        }
 /// <summary>
 /// Add parameters while fetch all color master
 /// </summary>
 /// <param name="users"></param>
 /// <returns></returns>
 public IDbDataParameter[] AddParamsGetColorMaster(ColorMaster ColorMaster)
 {
     parameters.Clear();
     parameters.Add(dbManager.CreateParameter("@ColorName", 50, ColorMaster.ColorName, DbType.String));
     return(parameters.ToArray());
 }
        /// <summary>
        /// Add and Edit Document
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditColor(ColorCustom data, long userId = 0)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var res = db.ColorMaster.Where(m => m.ColorId == data.colorId).FirstOrDefault();
                if (res == null)
                {
                    try
                    {
                        ColorMaster item = new ColorMaster();
                        item.ColorName        = data.colorName;
                        item.ColorCode        = data.colorCode;
                        item.ColorDescription = data.colorDescription;
                        item.IsActive         = true;
                        item.IsDeleted        = false;
                        item.CreatedBy        = userId;
                        item.CreatedOn        = DateTime.Now;
                        db.ColorMaster.Add(item);
                        db.SaveChanges();
                        obj.response = ResourceResponse.AddedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
                else
                {
                    try
                    {
                        res.ColorName        = data.colorName;
                        res.ColorCode        = data.colorCode;
                        res.ColorDescription = data.colorDescription;
                        res.ModifiedBy       = userId;
                        res.ModifiedOn       = DateTime.Now;
                        db.SaveChanges();
                        obj.response = ResourceResponse.UpdatedSucessfully;
                        obj.isStatus = true;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex); if (ex.InnerException != null)
                        {
                            log.Error(ex.InnerException.ToString());
                        }
                        obj.response = ResourceResponse.ExceptionMessage;
                        obj.isStatus = false;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex); if (ex.InnerException != null)
                {
                    log.Error(ex.InnerException.ToString());
                }
                obj.response = ResourceResponse.ExceptionMessage;
                obj.isStatus = false;
            }
            return(obj);
        }
        /// <summary>
        /// To get the color master list..
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        public DataTable GetColorMaster(ColorMaster ColorMaster)
        {
            var DbManager = new DBManager("DBConnection");

            return(DbManager.GetDataTable(_StoredProcedures.GetColorMaster_SP, CommandType.StoredProcedure, _AdminMasterIRepository.AddParamsGetColorMaster(ColorMaster)));
        }