public bool CategoryEditDuplicate(CategoryMaterModel cate) { try { DataTable dt = new DataTable(); dt = ToDataTable((from c in DB.DDCATE_MAST where c.CATE_CODE != Convert.ToString(cate.CateCode) && c.CATEGORY == cate.Category //&& ((Convert.ToBoolean(Convert.ToInt16(c.DELETE_FLAG)) == false) || (c.DELETE_FLAG == null)) select new { c.CATEGORY }).ToList()); if (dt != null) { if (dt.Rows.Count > 0) { return(true); } } else { return(false); } return(true); } catch (Exception e) { throw e.LogException(); } }
public bool AddEditCategory(CategoryMaterModel catemodel, ref string mode) { bool _status = false; DDCATE_MAST cate = new DDCATE_MAST(); try { cate = (from c in DB.DDCATE_MAST where c.CATE_CODE == catemodel.CateCode.ToValueAsString() select c).FirstOrDefault <DDCATE_MAST>(); if (cate == null) { try { cate = new DDCATE_MAST(); cate.CATE_CODE = catemodel.CateCode.ToString(); cate.CATEGORY = catemodel.Category; cate.ENTERED_DATE = DateTime.Now; cate.ENTERED_BY = userInformation.UserName; cate.DELETE_FLAG = catemodel.Active; cate.ROWID = Guid.NewGuid(); DB.DDCATE_MAST.InsertOnSubmit(cate); DB.SubmitChanges(); mode = "Add"; return(true); } catch (Exception e) { e.LogException(); DB.DDCATE_MAST.DeleteOnSubmit(cate); } } else { try { cate.CATEGORY = catemodel.Category; cate.UPDATED_DATE = DateTime.Now; cate.UPDATED_BY = userInformation.UserName; cate.DELETE_FLAG = catemodel.Active; DB.SubmitChanges(); mode = "Update"; return(true); } catch (Exception e) { e.LogException(); DB.DDCATE_MAST.Context.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, cate); } } } catch (Exception e) { throw e.LogException(); } return(_status); }
public CategoryViewModel(UserInformation userInfo) { this._onAddCommand = new DelegateCommand(this.Add); this._onEditViewCommand = new DelegateCommand(this.Edit); this._onSaveCommand = new DelegateCommand(this.Save); this._onCloseCommand = new DelegateCommand(this.Close); this._onDeleteCommand = new DelegateCommand(this.Delete); this.selectChangeComboCommandName = new DelegateCommand(this.SelectDataRow); CategoryModel = new CategoryMaterModel(); categoryBll = new CategoryBll(userInfo); GetRights(); ApplicationFocus = true; AddButtonIsEnable = true; Add(); SetdropDownItems(); setRights(); FocusButton = true; }
//public int GetCC(CategoryMaterModel catemodel) //{ // double serialno = 0; // serialno = (from s in DB.DDCATE_MAST // select s).Max(sno => sno.CATE_CODE.ToDoubleValue()); // serialno = serialno + 1; // return serialno.ToString().ToIntValue(); //} public int GetCC(CategoryMaterModel catemodel) { string cateSno = "1"; try { DataTable dataValue = new DataTable(); dataValue = ToDataTable((from o in DB.DDCATE_MAST select new { o.CATE_CODE }).ToList()); // cateSno = (from o in DB.DDCATE_MAST select o.CATE_CODE).Max(); // if (dataValue.Rows.Count > 0) cateSno = (Convert.ToUInt64(Convert.ToUInt32(dataValue.Rows.Count) + 1)).ToValueAsString(); return(cateSno.ToIntValue()); } catch (Exception ex) { cateSno = "1"; ex.LogException(); } return(cateSno.ToIntValue()); }