public int AssignBranchToUser(User user, Branch branch)
        {
            try
            {
                int rowAffected = 0;
                ConnectionObj.Open();
                CommandObj.CommandText = "spAssignBranchToUser";
                CommandObj.CommandType = CommandType.StoredProcedure;
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.AddWithValue("@UserId", user.UserId);
                CommandObj.Parameters.AddWithValue("@BranchId", branch.BranchId);
                CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
                CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
                CommandObj.ExecuteNonQuery();
                rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);


                return(rowAffected);
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                throw new Exception("Could not assign branch to user", exception);
            }
            finally
            {
                ConnectionObj.Close();
                CommandObj.Dispose();
                CommandObj.Parameters.Clear();
            }
        }
示例#2
0
        public int Insert(Teacher teacher)
        {
            try
            {
                CommandObj.CommandText = "spAddTeacher";
                CommandObj.CommandType = CommandType.StoredProcedure;
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.AddWithValue("@Name", teacher.Name);
                CommandObj.Parameters.AddWithValue("@Address", teacher.Address);
                CommandObj.Parameters.AddWithValue("@Email", teacher.Email.ToLower());
                CommandObj.Parameters.AddWithValue("@Contact", teacher.Contact);
                CommandObj.Parameters.AddWithValue("@DesignationId", teacher.DesignationId);
                CommandObj.Parameters.AddWithValue("@DepartmentId", teacher.DepartmentId);
                CommandObj.Parameters.AddWithValue("@CreditTobeTaken", teacher.CreditTobeTaken);
                CommandObj.Parameters.AddWithValue("@RemainingCredit", 0);
                ConnectionObj.Open();
                return(CommandObj.ExecuteNonQuery());
            }
            catch (Exception exception)
            {
                throw new Exception("Could Not save teacher", exception);
            }

            finally
            {
                ConnectionObj.Close();
                CommandObj.Dispose();
            }
        }
        public int Update(EnrollStudentInCourse enrollStudentInCourse)
        {
            ConnectionObj.Open();
            SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction();

            try
            {
                CommandObj.Transaction = sqlTransaction;
                CommandObj.CommandText = "UPDATE t_StudentEnrollInCourse SET IsStudentActive=1 WHERE StudentId='" + enrollStudentInCourse.StudentId + "' AND CourseId='" + enrollStudentInCourse.CourseId + "'";
                int updateResult = CommandObj.ExecuteNonQuery();

                // int updateResult = UpdateStudentEnrolledCourses(enrollStudentInCourse);
                sqlTransaction.Commit();
                return(updateResult);
            }
            catch (Exception exception)
            {
                sqlTransaction.Rollback();
                throw new Exception("Could not save", exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
 public int Insert(Course aCourse)
 {
     try
     {
         CommandObj.CommandText = "spAddCourse";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@Code", aCourse.Code.ToUpper());
         CommandObj.Parameters.AddWithValue("@Name", aCourse.Name);
         CommandObj.Parameters.AddWithValue("@Credit", aCourse.Credit);
         CommandObj.Parameters.AddWithValue("@Description", aCourse.Description);
         CommandObj.Parameters.AddWithValue("@DepartmentId", aCourse.DepartmentId);
         CommandObj.Parameters.AddWithValue("@SemesterId", aCourse.SemesterId);
         ConnectionObj.Open();
         return(CommandObj.ExecuteNonQuery());
     }
     catch (Exception exception)
     {
         throw new Exception("Unable to Seve course", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
     }
 }
示例#5
0
 public int Insert(City aCity)
 {
     try
     {
         string query = "INSERT INTO t_City VALUES(@name,@about,@noOfDwellers,@location,@weather,@countryId)";
         CommandObj.CommandText = query;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@name", aCity.Name);
         CommandObj.Parameters.AddWithValue("@about", aCity.About);
         CommandObj.Parameters.AddWithValue("@noOfDwellers", aCity.NoOfDewellers);
         CommandObj.Parameters.AddWithValue("@location", aCity.Location);
         CommandObj.Parameters.AddWithValue("@weather", aCity.Weather);
         CommandObj.Parameters.AddWithValue("@countryId", aCity.CountryId);
         ConnectionObj.Open();
         int rowAffected = CommandObj.ExecuteNonQuery();
         ConnectionObj.Close();
         CommandObj.Dispose();
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Unable not save", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
     }
 }
        public int Insert(CourseAssignToTeacher courseAssign)
        {
            ConnectionObj.Open();
            SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction();

            try
            {
                CommandObj.Transaction = sqlTransaction;
                CommandObj.CommandText = "INSERT INTO t_CourseAssignToTeacher VALUES(@deptId,@teacherId,@courseId,@status)";
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.AddWithValue("@deptId", courseAssign.DepartmentId);
                CommandObj.Parameters.AddWithValue("@teacherId", courseAssign.TeacherId);
                CommandObj.Parameters.AddWithValue("@courseId", courseAssign.CourseId);
                CommandObj.Parameters.AddWithValue("@status", 1);
                int rowAffected = CommandObj.ExecuteNonQuery();

                int updateResult = UpdateTeacher(courseAssign);
                sqlTransaction.Commit();
                return(rowAffected);
            }
            catch (Exception exception)
            {
                sqlTransaction.Rollback();
                throw new Exception("Could not save", exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
示例#7
0
 public int ChangeOrderStatusByManager(Order aModel)
 {
     try
     {
         CommandObj.CommandText = "spChangeOrderStatusByManager";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@OrderAndTransctionId", aModel.OrderId);
         CommandObj.Parameters.AddWithValue("@Status ", aModel.Status);
         CommandObj.Parameters.AddWithValue("@DeliveryDate", aModel.DeliveryDateTime);
         CommandObj.Parameters.AddWithValue("@DeliveryOrRcvUserId", aModel.DeliveredOrReceiveUserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not Change the Order status", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#8
0
 public int SaveRejectedProduct(RejectedProduct rejectedProduct)
 {
     try
     {
         CommandObj.CommandText = "UDSP_SaveRejectedProduct";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@Barcode", rejectedProduct.Barcode);
         CommandObj.Parameters.AddWithValue("@RejectionReasonId", rejectedProduct.RejectionReasonId);
         CommandObj.Parameters.AddWithValue("@Notes", rejectedProduct.Notes);
         CommandObj.Parameters.AddWithValue("@UserId", rejectedProduct.UserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not save rejected product", exception);
     }
     finally
     {
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
         ConnectionObj.Close();
     }
 }
        public int SaveDeliveredRequisitionDetails(List <ScannedProduct> scannedProducts, Delivery aDelivery, int inventoryId, int deliveryId)
        {
            int n = 0;
            int i = 0;

            foreach (var item in scannedProducts)
            {
                CommandObj.CommandText = "UDSP_SaveDeliveredRequisitionDetailsFromFactory";
                CommandObj.CommandType = CommandType.StoredProcedure;
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.AddWithValue("@ProductId", Convert.ToInt32(item.ProductCode.Substring(2, 3)));
                CommandObj.Parameters.AddWithValue("@ProductBarcode", item.ProductCode);
                CommandObj.Parameters.AddWithValue("@TransactionRef", aDelivery.DeliveryRef);
                CommandObj.Parameters.AddWithValue("@InventoryMasterId", inventoryId);
                CommandObj.Parameters.AddWithValue("@Status", 2);
                CommandObj.Parameters.AddWithValue("@DeliveryId", deliveryId);
                CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
                CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
                CommandObj.ExecuteNonQuery();
                n += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
            }

            if (n > 0)
            {
                i = SaveDeliveredItemWithQuantityToFactory(scannedProducts, inventoryId, aDelivery);
            }

            return(i);
        }
示例#10
0
 public int Add(BarCodeModel model)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddBarCode";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@PrintByUserId", model.PrintByUserId);
         CommandObj.Parameters.AddWithValue("@BarCode", model.Barcode);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not add barcode", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#11
0
 public int AddVerificationNotesToRejectedProduct(ProductVerificationModel verificationModel)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddVerificationNotesToRejectedProduct";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@Notes", verificationModel.Notes);
         CommandObj.Parameters.AddWithValue("@RejectionId", verificationModel.RejectionId);
         CommandObj.Parameters.AddWithValue("@VerifiedByUserId", verificationModel.VerifiedByUserId);
         CommandObj.Parameters.AddWithValue("@PassOrFailedStatus", verificationModel.QcPassorFailedStatus);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not add verification notes to rejected product", exception);
     }
     finally
     {
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
         ConnectionObj.Close();
     }
 }
示例#12
0
 public int AddNewUser(User user)
 {
     try
     {
         ConnectionObj.Open();
         CommandObj.CommandText = "spAddNewUser";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@UserName", user.UserName);
         CommandObj.Parameters.AddWithValue("@UserPassword", user.Password);
         CommandObj.Parameters.AddWithValue("@EmployeeId", user.EmployeeId);
         CommandObj.Parameters.AddWithValue("@AddedByUserId", user.AddedByUserId);
         CommandObj.Parameters.AddWithValue("@UseRoleId", user.UserRoleId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception e)
     {
         throw new Exception("Could not add user", e);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
 public int AssignRoleToUser(AssignRoleModel model)
 {
     try
     {
         ConnectionObj.Open();
         CommandObj.CommandText = "spAssignRoleToUser";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@UserId", model.UserId);
         CommandObj.Parameters.AddWithValue("@BranchId", model.BranchId);
         CommandObj.Parameters.AddWithValue("@RoleId", model.RoleId);
         CommandObj.Parameters.AddWithValue("@IsActive", model.ActiveStatus);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Could not assign role to user", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
 public int AssignForwardPermissionToUser(int userId, int actionId, int forwardToId)
 {
     try
     {
         CommandObj.CommandText = "spAssignForwardPermissionToUser";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@UserId", userId);
         CommandObj.Parameters.AddWithValue("@ViewId", actionId);
         CommandObj.Parameters.AddWithValue("@ForwartToId", forwardToId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Unable to assign forward permission to user", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#15
0
 public int UpdateEducationalInfo(EducationalInfo anEmployee)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddEducationalInfo";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@QualificationName", anEmployee.QualificationName);
         CommandObj.Parameters.AddWithValue("@GroupSubject", anEmployee.GroupSubject);
         CommandObj.Parameters.AddWithValue("@InstituteName", anEmployee.InstituteName);
         CommandObj.Parameters.AddWithValue("@BoardName", anEmployee.BoardName);
         CommandObj.Parameters.AddWithValue("@PassingYear", anEmployee.PassingYear);
         CommandObj.Parameters.AddWithValue("@Result", anEmployee.Result);
         CommandObj.Parameters.AddWithValue("@EmployeeId", anEmployee.EmployeeId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Could not Add educational Information", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
        private int SaveDispatchInformationDetails(DispatchModel model, long dispatchId, long inventoryMasterId)
        {
            int i = 0;
            int n = 0;

            foreach (var item in model.ScannedProducts)
            {
                CommandObj.Parameters.Clear();
                CommandObj.CommandText = "UDSP_SaveDispatchInformationDetails";
                CommandObj.CommandType = CommandType.StoredProcedure;

                CommandObj.Parameters.AddWithValue("@ProductId", Convert.ToInt32(item.ProductCode.Substring(2, 3)));
                CommandObj.Parameters.AddWithValue("@DispatchId", dispatchId);
                CommandObj.Parameters.AddWithValue("@ProductBarCode", item.ProductCode);
                CommandObj.Parameters.AddWithValue("@FactoryInventoryMasterId", inventoryMasterId);
                CommandObj.Parameters.AddWithValue("@TransactionRef", model.DispatchRef);
                CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
                CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
                CommandObj.ExecuteNonQuery();
                i += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
            }
            if (i > 0)
            {
                n = SaveDispatchItems(model, dispatchId, inventoryMasterId);
            }
            return(n);
        }
示例#17
0
 public int TransferEmployee(int empId, int fromBranchId, int toBranchId, string remarks, ViewUser user)
 {
     try
     {
         CommandObj.CommandText = "UDSP_TransferEmployee";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@EmployeeId", empId);
         CommandObj.Parameters.AddWithValue("@FromBranchId", fromBranchId);
         CommandObj.Parameters.AddWithValue("@ToBranchId", toBranchId);
         CommandObj.Parameters.AddWithValue("@Remarks", remarks);
         CommandObj.Parameters.AddWithValue("@TransferByUserId", user.UserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not Transfer Employee", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#18
0
 public int AddProductWarrentPolicy(WarrantyPolicy model)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddProductWarrentPolicy";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@ProductId", model.ProductId);
         CommandObj.Parameters.AddWithValue("@WarrantyFrom", model.WarrantyFrom);
         CommandObj.Parameters.AddWithValue("@WarrantyPeriodInDays", model.WarrantyPeriodInDays);
         CommandObj.Parameters.AddWithValue("@AgeLimitInDealerStock", model.AgeLimitInDealerStock);
         CommandObj.Parameters.AddWithValue("@UserId", model.UserId);
         CommandObj.Parameters.AddWithValue("@FromBatch", model.FromBatch ?? (object)DBNull.Value);
         CommandObj.Parameters.AddWithValue("@ToBatch", model.ToBatch ?? (object)DBNull.Value);
         CommandObj.Parameters.AddWithValue("@ClientId", model.ClientId ?? (object)DBNull.Value);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Coluld not add product warrenty policy");
     }
     finally
     {
         CommandObj.Dispose();
         ConnectionObj.Close();
         CommandObj.Parameters.Clear();
     }
 }
        public int Update(CourseAssignToTeacher courseAssign)
        {
            ConnectionObj.Open();
            SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction();

            try
            {
                CommandObj.Transaction = sqlTransaction;
                CommandObj.CommandText = "UPDATE t_CourseAssignToTeacher SET IsActive=1 WHERE TeacherId='" + courseAssign.TeacherId + "' AND CourseId='" + courseAssign.CourseId + "'";
                CommandObj.ExecuteNonQuery();

                int updateResult = UpdateTeacher(courseAssign);
                sqlTransaction.Commit();
                return(updateResult);
            }
            catch (Exception exception)
            {
                sqlTransaction.Rollback();
                throw new Exception("Could not save", exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
示例#20
0
 public int Update(WarrantyPolicy model)
 {
     try
     {
         CommandObj.CommandText = "UDSP_UpdateWarrantyPolicy";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@Id", model.Id);
         CommandObj.Parameters.AddWithValue("@WarrantyPeriod", model.WarrantyPeriodInDays);
         CommandObj.Parameters.AddWithValue("@AgeLimitInDealerStock", model.AgeLimitInDealerStock);
         CommandObj.Parameters.AddWithValue("@HasWarrantyCard", model.HasWarrantyCard);
         CommandObj.Parameters.AddWithValue("@ProductId", model.ProductId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Coluld not update product warrenty policy");
     }
     finally
     {
         CommandObj.Dispose();
         ConnectionObj.Close();
         CommandObj.Parameters.Clear();
     }
 }
        public int UnAssignCourse()
        {
            ConnectionObj.Open();
            SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction();

            try
            {
                CommandObj.CommandText = "UPDATE t_CourseAssignToTeacher SET IsActive=0";
                CommandObj.Transaction = sqlTransaction;
                CommandObj.ExecuteNonQuery();
                teacherGateway.UpdateTeacherInformation();
                int a = ResetStudentResult();
                int i = UnAssignStudentCourse();
                sqlTransaction.Commit();
                return(i);
            }
            catch (Exception exception)
            {
                sqlTransaction.Rollback();
                throw new Exception("Failed to Unassign course", exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
示例#22
0
 public int SaveTestPolicy(TestPolicyModel model)
 {
     try
     {
         CommandObj.CommandText = "UDSP_SaveTestPolicy";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@TestCategoryId", model.TestCategoryId);
         CommandObj.Parameters.AddWithValue("@ProductId", model.ProductId);
         CommandObj.Parameters.AddWithValue("@Parameter", model.Parameter);
         CommandObj.Parameters.AddWithValue("@AcceptableValue", model.AcceptableValue);
         CommandObj.Parameters.AddWithValue("@Remarks", model.Remarks);
         CommandObj.Parameters.AddWithValue("@UserId", model.UserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Coluld not add product test policy");
     }
     finally
     {
         CommandObj.Dispose();
         ConnectionObj.Close();
         CommandObj.Parameters.Clear();
     }
 }
 public int Add(EmployeeType model)
 {
     try
     {
         CommandObj.CommandText = "spAddNewEmployeeType";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.Clear();
         CommandObj.Parameters.AddWithValue("@TypeName", model.EmployeeTypeName);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         throw new Exception("Could not add employee Type", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
 public int UnAssignUpazillaFromTerritory(int territoryDetailsId, string reason, ViewUser user)
 {
     try
     {
         CommandObj.CommandText = "UDSP_UnAssignUpazillaFromTerritory";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@TerritoryDetailsId", territoryDetailsId);
         CommandObj.Parameters.AddWithValue("@Reason", reason);
         CommandObj.Parameters.AddWithValue("@UnAssignedByUserId", user.UserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new  Exception("Could not Unassign upazilla", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Parameters.Clear();
         CommandObj.Dispose();
     }
 }
示例#25
0
 public int Add(Discount discount)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddDiscount";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@ProductId", discount.ProductId);
         CommandObj.Parameters.AddWithValue("@ClientTypeId", discount.ClientTypeId);
         CommandObj.Parameters.AddWithValue("@DiscountPercent", discount.DiscountPercent);
         CommandObj.Parameters.AddWithValue("@UpdatedByUserId", discount.UpdateByUserId);
         CommandObj.Parameters.AddWithValue("@UpdateDate", discount.UpdateDate);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         var rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not add discount", exception);
     }
     finally
     {
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
         ConnectionObj.Close();
     }
 }
 public int Add(Territory aTerritory)
 {
     try
     {
         CommandObj.CommandText = "spAddNewTerritory";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@RegionId", aTerritory.RegionId);
         CommandObj.Parameters.AddWithValue("@TerittoryName", aTerritory.TerritoryName);
         CommandObj.Parameters.AddWithValue("@Description", aTerritory.Description ?? (object)DBNull.Value);
         CommandObj.Parameters.AddWithValue("@Alias", aTerritory.TerritoryName ?? (object)DBNull.Value);
         CommandObj.Parameters.AddWithValue("@AddedByUserId", aTerritory.AddedByUserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not Save territory info", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#27
0
 public int Add(Vat vat)
 {
     try
     {
         CommandObj.CommandText = "UDSP_AddVat";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@ProductId", vat.ProductId);
         CommandObj.Parameters.AddWithValue("@VatAmount", vat.VatAmount);
         CommandObj.Parameters.AddWithValue("@UpdateDate", vat.UpdateDate);
         CommandObj.Parameters.AddWithValue("@UpdateByUserId", vat.UpdateByUserId);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not save Vat info", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }
示例#28
0
        public string SaveInformationIntoDb(Registation registation)
        {
            string insertSql = "INSERT INTO tbl_user (";

            insertSql += "user_id, user_pass, user_email, user_type,retryAttemps,isLocked) ";
            insertSql += "VALUES (";
            insertSql += "@userid, @userpass, @useremail, @usertype,@retryAttemps,@isLocked)";

            ConnectionObj.Open();
            CommandObj.CommandText = insertSql;
            CommandObj.Parameters.AddWithValue("@userid", registation.UserId);
            CommandObj.Parameters.AddWithValue("@userpass", registation.Password);
            CommandObj.Parameters.AddWithValue("@useremail", registation.Email);
            CommandObj.Parameters.AddWithValue("@usertype", registation.Type);
            CommandObj.Parameters.AddWithValue("@retryAttemps", registation.RetryAttemps);
            CommandObj.Parameters.AddWithValue("@isLocked", registation.Islocked);

            int saveRowAffected = CommandObj.ExecuteNonQuery();

            ConnectionObj.Close();
            if (saveRowAffected > 0)
            {
                return("success");
            }
            return("Save Failed");
        }
        public int Insert(Student aStudent)
        {
            try
            {
                string query = "INSERT INTO t_Student VALUES(@RegNo,@Name,@Email,@ContactNo,@RegisterationDate,@Address,@DepartmentId)";
                CommandObj.CommandText = query;

                CommandObj.Parameters.Clear();

                CommandObj.Parameters.AddWithValue("@RegNo", aStudent.RegNo);
                CommandObj.Parameters.AddWithValue("@Name", aStudent.Name);
                CommandObj.Parameters.AddWithValue("@Email", aStudent.Email.ToLower());
                CommandObj.Parameters.AddWithValue("@ContactNo", aStudent.Contact);
                CommandObj.Parameters.AddWithValue("@RegisterationDate", aStudent.RegDate.ToShortDateString());
                CommandObj.Parameters.AddWithValue("@Address", aStudent.Address);
                CommandObj.Parameters.AddWithValue("@DepartmentId", aStudent.DepartmentId);
                ConnectionObj.Open();
                int rowAffected = CommandObj.ExecuteNonQuery();
                return(rowAffected);
            }
            catch (Exception exception)
            {
                throw new Exception("Could Not save", exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
示例#30
0
 public int Add(Department aDepartment)
 {
     try
     {
         CommandObj.CommandText = "spAddNewDepartment";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@DepartmentCode", aDepartment.DepartmentCode);
         CommandObj.Parameters.AddWithValue("@DepartmentName", aDepartment.DepartmentName);
         CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int);
         CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output;
         ConnectionObj.Open();
         CommandObj.ExecuteNonQuery();
         int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value);
         return(rowAffected);
     }
     catch (SqlException sqlException)
     {
         if (sqlException.Number == 2601)
         {
             throw new Exception("Cannot insert duplicate key", sqlException);
         }
         throw new Exception("Could not Save department", sqlException);
     }
     catch (Exception exception)
     {
         throw new Exception("Could not Save department", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }