Beispiel #1
0
 public string AddUpdateBranch(Branch_tbl branch)
 {
     if (branch != null)
     {
         if (branch.id == 0)
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 branch.Create_by   = 1;
                 branch.Create_Date = DateTime.Now;
                 dataContext.Branch_tbl.Add(branch);
                 try
                 {
                     dataContext.SaveChanges();
                     err = "Branch Added Successfully";
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
         else
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 int no         = Convert.ToInt32(branch.id);
                 var branchList = dataContext.Branch_tbl.Where(x => x.id == no).FirstOrDefault();
                 branchList.Branch_Code = branch.Branch_Code;
                 branchList.Branch_Name = branch.Branch_Name;
                 branchList.Status      = branch.Status;
                 branchList.Update_by   = 1;
                 branchList.Update_Date = DateTime.Now;
                 try
                 {
                     dataContext.SaveChanges();
                     return("Branch Updated Successfully");
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
     }
     else
     {
         err = "Invalid Item";
     }
     return(err);
 }
Beispiel #2
0
 public string AddUpdateDesignation(Designation_tbl design)
 {
     if (design != null)
     {
         if (design.id == 0)
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 design.Create_by   = 1;
                 design.Create_Date = DateTime.Now;
                 dataContext.Designation_tbl.Add(design);
                 try
                 {
                     dataContext.SaveChanges();
                     err = "Designation Added Successfully";
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
         else
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 int no = Convert.ToInt32(design.id);
                 var designationList = dataContext.Designation_tbl.Where(x => x.id == no).FirstOrDefault();
                 designationList.Designation = design.Designation;
                 designationList.Status      = design.Status;
                 designationList.Update_by   = 1;
                 designationList.Update_Date = DateTime.Now;
                 try
                 {
                     dataContext.SaveChanges();
                     return("Designation Updated Successfully");
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
     }
     else
     {
         err = "Invalid Item";
     }
     return(err);
 }
Beispiel #3
0
 public string AddUpdateSalaryDeduction(SalaryDeduction_tbl sHead)
 {
     if (sHead != null)
     {
         if (sHead.id == 0)
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 sHead.Create_by   = 1;
                 sHead.Create_Date = DateTime.Now;
                 dataContext.SalaryDeduction_tbl.Add(sHead);
                 try
                 {
                     dataContext.SaveChanges();
                     err = "Salary Head Added Successfully";
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
         else
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 int no             = Convert.ToInt32(sHead.id);
                 var salaryHeadList = dataContext.SalaryDeduction_tbl.Where(x => x.id == no).FirstOrDefault();
                 salaryHeadList.DeductionType = sHead.DeductionType;
                 salaryHeadList.Status        = sHead.Status;
                 salaryHeadList.Update_by     = 1;
                 salaryHeadList.Update_Date   = DateTime.Now;
                 try
                 {
                     dataContext.SaveChanges();
                     return("Salary Head Updated Successfully");
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
     }
     else
     {
         err = "Invalid Item";
     }
     return(err);
 }
Beispiel #4
0
 public string AddUpdateEmployee(Employee_tbl employee, HttpPostedFileBase file)
 {
     if (employee != null)
     {
         if (employee.id == 0)
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 var allowedExtensions = new[] {
                     ".Jpg", ".png", ".jpg", "jpeg"
                 };
                 //tbl.Id = fc["Id"].ToString();
                 //tbl.Image_url = file.ToString(); //getting complete url
                 //tbl.Name = fc["Name"].ToString();
                 //var fileName = Path.GetFileName(file.FileName); //getting only file name(ex-ganesh.jpg)
                 //var ext = Path.GetExtension(file.FileName); //getting the extension(ex-.jpg)
                 //if (allowedExtensions.Contains(ext)) //check what type of extension
                 //{
                 //	string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                 //	string myfile = name + "_" + tbl.Id + ext; //appending the name with id
                 //											   // store the file inside ~/project folder(Img)
                 //	var path = Path.Combine(Server.MapPath("~/Img"), myfile);
                 //	tbl.Image_url = path;
                 //	obj.tbl_details.Add(tbl);
                 //	obj.SaveChanges();
                 //	file.SaveAs(path);
                 //}
                 employee.Create_by   = 1;
                 employee.Create_Date = DateTime.Now;
                 dataContext.Employee_tbl.Add(employee);
                 try
                 {
                     dataContext.SaveChanges();
                     err = "employee Added Successfully";
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
         else
         {
             using (PayRoll_Entities dataContext = new PayRoll_Entities())
             {
                 int no      = Convert.ToInt32(employee.id);
                 var empList = dataContext.Employee_tbl.Where(x => x.id == no).FirstOrDefault();
                 empList.Employee_Code      = employee.Employee_Code;
                 empList.First_Name         = employee.First_Name;
                 empList.Last_Name          = employee.Last_Name;
                 empList.Gender             = employee.Gender;
                 empList.DOB                = employee.DOB;
                 empList.DOJ                = employee.DOJ;
                 empList.Email              = employee.Email;
                 empList.Mobile             = employee.Mobile;
                 empList.Designation        = employee.Designation;
                 empList.Branch             = employee.Branch;
                 empList.Present_Address1   = employee.Present_Address1;
                 empList.Present_Address2   = employee.Present_Address2;
                 empList.Present_City       = employee.Present_City;
                 empList.Present_State      = employee.Present_State;
                 empList.Present_Pincode    = employee.Present_Pincode;
                 empList.Permanent_Address1 = employee.Permanent_Address1;
                 empList.Permanent_Address2 = employee.Permanent_Address2;
                 empList.Permanent_City     = employee.Permanent_City;
                 empList.Permanent_State    = employee.Permanent_State;
                 empList.Permanent_Pincode  = employee.Permanent_Pincode;
                 empList.Bank_Name          = employee.Bank_Name;
                 empList.Account_No         = employee.Account_No;
                 empList.IFSC_Code          = employee.IFSC_Code;
                 empList.Branch_Name        = employee.Branch_Name;
                 empList.Status             = employee.Status;
                 empList.User_Id            = employee.User_Id;
                 empList.Update_by          = 1;
                 empList.Update_Date        = DateTime.Now;
                 empList.ProfileImage       = employee.ProfileImage;
                 try
                 {
                     dataContext.SaveChanges();
                     return("Employee Updated Successfully");
                 }
                 catch (Exception ex)
                 {
                     HandleException(ex);
                 }
             }
         }
     }
     else
     {
         err = "Invalid Item";
     }
     return(err);
 }