public bool UserRoleSubmit(rStaffRole model) { var db = new dbsmappEntities(); var account = db.userapps.FirstOrDefault(s => s.userid.Equals(model.userid)); var currentUser = db.C_User.FirstOrDefault(s => s.UserName.Equals(account.userid)); var isExist = db.userapproles.FirstOrDefault(s => s.userid.Equals(model.userid) && s.role.Equals(model.role)); if (isExist != null) { return(false); } db.userapproles.Add(new userapprole() { userid = model.userid, role = model.role, remarks = "", status = "activated" }); db.SaveChanges(); return(true); }
public bool RemoveDepartment(string DeptCode) { var db = new dbsmappEntities(); var sdept = db.sdepartments.FirstOrDefault(s => s.deptcode.Equals(DeptCode)); if (sdept != null) { var sdepts = db.sdepartmentservices.Where(s => s.deptcode.Equals(DeptCode)).ToList(); foreach (var item in sdepts) { db.sdepartmentservices.Remove(item); } db.sdepartments.Remove(sdept); db.SaveChanges(); return(true); } else { return(false); } }
public bool AddProductPrice(iproductprice price) { var db = new dbsmappEntities(); var pprice = db.iproductprices.FirstOrDefault(s => s.itemcode.Equals(price.itemcode)); if (pprice == null) { price.status = "new"; NullFiller.FillNullFields <iproductprice>(price); Capitalize.UppercaseClassFields <iproductprice>(price); db.iproductprices.Add(price); } else { pprice.sellingprice = price.sellingprice; pprice.purchasingprice = price.purchasingprice; pprice.vatprice = price.vatprice; pprice.remarks = price.remarks; } db.SaveChanges(); return(true); }
public bool AddDepartmentServices(string ServCode, string DeptCode) { var db = new dbsmappEntities(); var sdept = db.sdepartmentservices.FirstOrDefault(s => s.deptcode.Equals(DeptCode) && s.servicecode.Equals(ServCode)); if (sdept == null) { db.sdepartmentservices.Add(new sdepartmentservice { deptcode = DeptCode, servicecode = ServCode, remarks = "", status = "ACTIVATED" }); db.SaveChanges(); return(true); } else { return(false); } }
public bool AddBranchOrder(xbc branch) { var db = new dbsmappEntities(); var newGeneratedId = new NewId()._GenerateId("xbranchorders"); var NewIDD = "B00" + newGeneratedId + "H" + DateTime.Today.ToString("yyyy"); var username = User.Identity.GetUserName(); db.xbranchorders.Add(new xbranchorder { branchcode = branch.brn, servicecode = branch.servicecode, ordercode = NewIDD, orderby = username, datecreated = DateTime.Now, approvedby = "", dateapproved = DateTime.Now, remarks = branch.remarks, status = "blank", }); db.SaveChanges(); return(true); }
public bool AddProductToOrder(string itemcode, string ordercode, string quantity) { var db = new dbsmappEntities(); var serv = db.xbranchorderslists.FirstOrDefault(s => s.itemcode.Equals(itemcode) && s.ordercode.Equals(ordercode)); if (serv == null) { db.xbranchorderslists.Add(new xbranchorderslist { ordercode = ordercode, itemcode = itemcode, quantity = quantity, status = "ordered" }); db.SaveChanges(); return(true); } else { return(false); } }
public bool AddBranch(xbranch branch) { var db = new dbsmappEntities(); var brn = db.xbranches.FirstOrDefault(s => s.branchcode.Equals(branch.branchcode)); if (brn == null) { NullFiller.FillNullFields <xbranch>(branch); Capitalize.UppercaseClassFields <xbranch>(branch); db.xbranches.Add(branch); } else { NullFiller.FillNullFields <xbranch>(branch); Capitalize.UppercaseClassFields <xbranch>(branch); brn.branchname = branch.branchname; brn.remarks = branch.remarks; } db.SaveChanges(); return(true); }
public bool AddProduct(iproduct product) { var db = new dbsmappEntities(); var prod = db.iproducts.FirstOrDefault(s => s.barcode.Equals(product.barcode)); if (prod == null) { product.status = "activated"; NullFiller.FillNullFields <iproduct>(product); Capitalize.UppercaseClassFields <iproduct>(product); db.iproducts.Add(product); var files = Request.Files; if (files.Count != 0) { new ImageFunc().UploadProductPic(Request.Files, product.itemcode + "P"); } db.SaveChanges(); return(true); } else { return(false); } }
public bool AddServicesProduct(string datalist) { var db = new dbsmappEntities(); foreach (var item in datalist.Split(',')) { var xo = item.Split('-'); var sscode = xo[0].ToString(); var ssitemcode = xo[1].ToString(); var ssprice = xo[2].ToString(); var serv = db.nservicesproductprices.FirstOrDefault(s => s.itemcode.Equals(sscode) && s.servicescode.Equals(ssitemcode)); db.nservicesproductprices.Add(new nservicesproductprice { servicescode = sscode, itemcode = ssitemcode, price = ssprice, remarks = "", status = "ACTIVATED" }); } db.SaveChanges(); return(true); }
public bool AddProductToServices(string ServCode, string itemcode) { var db = new dbsmappEntities(); var serv = db.nservicesproducts.FirstOrDefault(s => s.itemcode.Equals(itemcode) && s.servicescode.Equals(ServCode)); if (serv == null) { db.nservicesproducts.Add(new nservicesproduct { servicescode = ServCode, itemcode = itemcode, usage = "", remarks = "", status = "Acivated" }); db.SaveChanges(); return(true); } else { return(false); } }
public bool UserBranchSubmit(rStaffBranch model) { var db = new dbsmappEntities(); var isExist = db.userappbranches.FirstOrDefault(s => s.userid.Equals(model.userid) && s.branchcode.Equals(model.branchcode)); if (isExist != null) { return(false); } else { db.userappbranches.Add(new userappbranch { branchcode = model.branchcode, userid = model.userid, remarks = "", status = "ACTIVATED" }); db.SaveChanges(); return(true); } }
public bool AddDepartment(sdepartment Department) { var db = new dbsmappEntities(); var dept = db.sdepartments.FirstOrDefault(s => s.deptcode.Equals(Department.deptcode)); if (dept == null) { Department.status = "activated"; NullFiller.FillNullFields <sdepartment>(Department); Capitalize.UppercaseClassFields <sdepartment>(Department); db.sdepartments.Add(Department); } else { NullFiller.FillNullFields <sdepartment>(Department); Capitalize.UppercaseClassFields <sdepartment>(Department); dept.deptcode = Department.deptcode; dept.deptname = Department.deptname; dept.remarks = Department.remarks; dept.status = "ACTIVATED"; } db.SaveChanges(); return(true); }
public async Task <bool> UserSubmit(rUser model) { NullFiller.FillNullFields <rUser>(model); Capitalize.UppercaseClassFields <rUser>(model); var db = new dbsmappEntities(); var isExist = db.userapps.FirstOrDefault(s => s.userid.Equals(model.userid)); if (isExist != null) { return(false); } var emailAdd = model.userid + "@danubeco.com"; var newuserid = model.userid + "JED"; var user = new User { UserName = newuserid, Email = emailAdd, Region = "JED" }; //var rnpw = System.Web.Security.Membership.GeneratePassword(6, 0); var result = await UserManager.CreateAsync(user, "12345678"); if (!result.Succeeded) { return(false); } var currentUser = await UserManager.FindByEmailAsync(emailAdd); await UserManager.AddToRolesAsync(currentUser.Id, model.role); db.userapps.Add(new userapp() { userid = newuserid, empid = model.userid, name = model.name, role = model.role, status = "activated", login = DateTime.Today, password = "******" }); var files = Request.Files; if (files.Count != 0) { new ImageFunc().UploadProductPic(Request.Files, newuserid); } db.SaveChanges(); return(true); }
public string UploadProductPic(HttpFileCollectionBase Files, string imgcode) { dbsmappEntities db = new dbsmappEntities(); var filepath = ""; if (Files == null) { filepath = ""; } for (int i = 0; i < Files.Count; i++) { var file = Files[i].FileName; var imgQQ = imgcode + ".jpg"; var absolutePath = HostingEnvironment.MapPath("~/Uploadpic/" + imgQQ); // Trash Garbage Collection if (File.Exists(absolutePath)) { System.GC.Collect(); System.GC.WaitForPendingFinalizers(); File.Delete(absolutePath); } filepath = HostingEnvironment.MapPath("~/Uploadpic/") + imgQQ; // Save Original Image Files[i].SaveAs(filepath); // Thumbnail ImagePro(filepath, imgQQ); // Save Pic Information db.ysysphotoes.Add(new ysysphoto() { imgcode = imgcode, picthmb = "", remarks = "", status = "", }); db.SaveChanges(); } return(filepath); }
public async Task <bool> LoginRole(xxRB rb) { var db = new dbsmappEntities(); var username = User.Identity.GetUserName(); var userid = User.Identity.GetUserId(); var isExist = db.userappsessions.FirstOrDefault(s => s.userid.Equals(username)); if (isExist != null) { db.userappsessions.Remove(isExist); await UserManager.RemoveFromRoleAsync(userid, isExist.role); } // STEP 1 await UserManager.AddToRolesAsync(userid, rb.role); db.userappsessions.Add(new userappsession { userid = username, role = rb.role, status = (rb.branch == null) ? "000" : rb.branch }); db.SaveChanges(); // STEP 2 SignInManager.AuthenticationManager.SignOut(); var cpass = db.userapps.FirstOrDefault(s => s.userid.Equals(username)).password; var result = await SignInManager.PasswordSignInAsync(username, cpass, false, false); switch (result) { case SignInStatus.Success: return(true); default: return(false); } }
public bool RemoveProductToServices(string ServCode, string itemcode) { var db = new dbsmappEntities(); var serv = db.nservicesproducts.FirstOrDefault(s => s.itemcode.Equals(itemcode) && s.servicescode.Equals(ServCode)); if (serv != null) { db.nservicesproducts.Remove(serv); db.SaveChanges(); return(true); } else { return(false); } }
public bool UserRemoveBranch(rStaffBranch model) { var db = new dbsmappEntities(); var isExist = db.userappbranches.FirstOrDefault(s => s.userid.Equals(model.userid) && s.branchcode.Equals(model.branchcode)); if (isExist == null) { return(false); } else { db.userappbranches.Remove(isExist); db.SaveChanges(); return(true); } }
public bool DeleteBranch(string branchcode) { var db = new dbsmappEntities(); var brn = db.xbranches.FirstOrDefault(s => s.branchcode.Equals(branchcode)); if (brn != null) { db.xbranches.Remove(brn); db.SaveChanges(); return(true); } else { return(false); } }
public bool DeleteProductToOrder(string itemcode, string ordercode) { var db = new dbsmappEntities(); var prd = db.xbranchorderslists.FirstOrDefault(s => s.itemcode.Equals(itemcode) && s.ordercode.Equals(ordercode)); if (prd != null) { db.xbranchorderslists.Remove(prd); db.SaveChanges(); return(true); } else { return(false); } }
public bool UpdateBranchOrder(string ordercode) { var db = new dbsmappEntities(); var serv = db.xbranchorders.FirstOrDefault(s => s.ordercode.Equals(ordercode)); if (serv != null) { serv.status = "pending"; db.SaveChanges(); return(true); } else { return(false); } }
public bool RemoveDepartmentServices(string ServCode, string DeptCode) { var db = new dbsmappEntities(); var sdept = db.sdepartmentservices.FirstOrDefault(s => s.deptcode.Equals(DeptCode) && s.servicecode.Equals(ServCode)); if (sdept != null) { db.sdepartmentservices.Remove(sdept); db.SaveChanges(); return(true); } else { return(false); } }
public bool AddServices(nservice services) { var db = new dbsmappEntities(); var serv = db.nservices.FirstOrDefault(s => s.servicescode.Equals(services.servicescode)); if (serv == null) { NullFiller.FillNullFields <nservice>(services); Capitalize.UppercaseClassFields <nservice>(services); db.nservices.Add(services); } else { NullFiller.FillNullFields <nservice>(services); Capitalize.UppercaseClassFields <nservice>(services); serv.servicename = services.servicename; serv.description = services.description; serv.departmentid = services.departmentid; serv.nprice = services.nprice; serv.sprice = services.sprice; serv.minutes = services.minutes; serv.hours = services.hours; serv.fixedcommission = services.fixedcommission; serv.remarks = services.remarks; serv.status = services.status; } var files = Request.Files; if (files.Count != 0) { new ImageFunc().UploadProductPic(Request.Files, services.servicescode + "S"); } db.SaveChanges(); return(true); }
public bool DeleteProduct(string itemcode) { var db = new dbsmappEntities(); var prod = db.iproducts.FirstOrDefault(s => s.itemcode.Equals(itemcode)); if (prod == null) { return(false); } else { db.iproducts.Remove(prod); var item1 = db.nservicesproductprices.FirstOrDefault(s => s.itemcode.Equals(itemcode)); if (item1 != null) { db.nservicesproductprices.Remove(item1); } var item2 = db.nservicesproducts.FirstOrDefault(s => s.itemcode.Equals(itemcode)); if (item2 != null) { db.nservicesproducts.Remove(item2); } var picExist = db.ysysphotoes.FirstOrDefault(s => s.imgcode.Equals(itemcode)); if (picExist != null) { db.ysysphotoes.Remove(picExist); new ImageFunc().RemoveProductPic(picExist.imgcode); } db.SaveChanges(); return(true); } }
public bool UpdateProduct(iproduct product) { var db = new dbsmappEntities(); var prod = db.iproducts.FirstOrDefault(s => s.itemcode.Equals(product.itemcode)); if (prod == null) { return(false); } else { NullFiller.FillNullFields <iproduct>(product); Capitalize.UppercaseClassFields <iproduct>(product); prod.itemcode = product.itemcode; prod.barcode = product.barcode; prod.modelno = product.modelno; prod.serialno = product.serialno; prod.arname = product.arname; prod.enname = product.enname; prod.arshortname = product.arshortname; prod.enshortname = product.enshortname; prod.size = product.size; prod.unit = product.unit; prod.remarks = product.remarks; prod.status = product.status; var files = Request.Files; if (files.Count != 0) { new ImageFunc().UploadProductPic(Request.Files, product.itemcode + "P"); } db.SaveChanges(); return(true); } }
public bool RemoveServices(string ServCode) { var db = new dbsmappEntities(); var serv = db.nservices.FirstOrDefault(s => s.servicescode.Equals(ServCode)); if (serv != null) { //------------------------ Service Products Price var getallnspp = db.nservicesproductprices.Where(s => s.servicescode.Equals(ServCode)).ToList(); foreach (var item in getallnspp) { db.nservicesproductprices.Remove(item); } //------------------------ Service Products var getallnsp = db.nservicesproducts.Where(s => s.servicescode.Equals(ServCode)).ToList(); foreach (var item in getallnsp) { db.nservicesproducts.Remove(item); } //------------------------ Service db.nservices.Remove(serv); db.SaveChanges(); return(true); } else { return(false); } }
public async Task <bool> UserRemoveRole(rStaffRole model) { var db = new dbsmappEntities(); var isExist = db.userapproles.FirstOrDefault(s => s.userid.Equals(model.userid) && s.role.Equals(model.role)); if (isExist == null) { return(false); } else { var currentUser = db.C_User.FirstOrDefault(s => s.UserName.Equals(model.userid)); await UserManager.RemoveFromRoleAsync(currentUser.UserId, model.role); db.userapproles.Remove(isExist); db.SaveChanges(); return(true); } }
public async Task <ActionResult> LogOff() { var db = new dbsmappEntities(); var username = User.Identity.GetUserName(); var userid = User.Identity.GetUserId(); var isExist = db.userappsessions.FirstOrDefault(s => s.userid.Equals(username)); if (isExist != null) { await UserManager.RemoveFromRoleAsync(userid, isExist.role); db.userappsessions.Remove(isExist); db.SaveChanges(); } SignInManager.AuthenticationManager.SignOut(); return(View()); }
public async Task <bool> ResetPassword(nResetPasswordViewModel model) { try { var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); if (user == null) { return(false); } user.PasswordHash = UserManager.PasswordHasher.HashPassword(model.nPassword); var result = await UserManager.UpdateAsync(user); if (!result.Succeeded) { return(false); } else { var db = new dbsmappEntities(); var isPerson = db.userapps.FirstOrDefault(s => s.userid.Equals(user.UserName)); isPerson.password = model.nPassword; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }