Example #1
0
        public PromotionEarningDetails objGetPromotionEarningDetails(string EmployeeId)
        {
            PromotionEarningDetails argPromotionEarningDetails = new PromotionEarningDetails();
            DataSet DataSetToFill = new DataSet();

            if (EmployeeId.ToString().Trim() == "")
            {
                goto ErrorHandlers;
            }

            DataSetToFill = this.GetPromotionEarningDetails4ID(EmployeeId.ToString().Trim());

            if (DataSetToFill.Tables[0].Rows.Count <= 0)
            {
                goto Finish;
            }

            argPromotionEarningDetails = this.objCretePromotionEarningDetails((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;

            return(argPromotionEarningDetails);
        }
Example #2
0
        private PromotionEarningDetails objCretePromotionEarningDetails(DataRow dr)
        {
            PromotionEarningDetails tPromotionEarningDetails = new PromotionEarningDetails();

            tPromotionEarningDetails.SetObjectInfo(dr);

            return(tPromotionEarningDetails);
        }
Example #3
0
        public string InsertPromotionEarningDetails(PromotionEarningDetails argPromotionEarningDetails, DataAccess da, List <ErrorHandlerClass> lstErr)
        {
            da.Open_Connection();

            SqlParameter[] param = new SqlParameter[15];
            param[0] = new SqlParameter("@EmployeeId", argPromotionEarningDetails.EmployeeId);
            param[1] = new SqlParameter("@Allowances", argPromotionEarningDetails.Allowances);
            param[2] = new SqlParameter("@Amount", argPromotionEarningDetails.Amount);
            param[3] = new SqlParameter("@CalcOn", argPromotionEarningDetails.CalcOn);
            param[4] = new SqlParameter("@PaymentMode", argPromotionEarningDetails.PaymentMode);
            param[5] = new SqlParameter("@Bonus", argPromotionEarningDetails.Bonus);
            param[6] = new SqlParameter("@OT", argPromotionEarningDetails.OT);

            param[7]  = new SqlParameter("@CreatedBy", argPromotionEarningDetails.CreatedBy);
            param[8]  = new SqlParameter("@ModifiedBy", argPromotionEarningDetails.ModifiedBy);
            param[9]  = new SqlParameter("@ItemNo", argPromotionEarningDetails.ItemNo);
            param[10] = new SqlParameter("@NewAmount", argPromotionEarningDetails.NewAmount);
            param[11] = new SqlParameter("@EmployeePromotionNo", argPromotionEarningDetails.EmployeePromotionNo);

            param[12]           = new SqlParameter("@Type", SqlDbType.Char);
            param[12].Size      = 1;
            param[12].Direction = ParameterDirection.Output;

            param[13]           = new SqlParameter("@Message", SqlDbType.VarChar);
            param[13].Size      = 255;
            param[13].Direction = ParameterDirection.Output;

            param[14]           = new SqlParameter("@returnvalue", SqlDbType.VarChar);
            param[14].Size      = 20;
            param[14].Direction = ParameterDirection.Output;

            int i = da.NExecuteNonQuery("Proc_InsertPromotionEarningDetails", param);

            string strMessage  = Convert.ToString(param[13].Value);
            string strType     = Convert.ToString(param[12].Value);
            string strRetValue = Convert.ToString(param[14].Value);

            objErrorHandlerClass.Type        = strType;
            objErrorHandlerClass.MsgId       = 0;
            objErrorHandlerClass.Message     = strMessage.ToString();
            objErrorHandlerClass.RowNo       = 0;
            objErrorHandlerClass.FieldName   = "";
            objErrorHandlerClass.LogCode     = "";
            objErrorHandlerClass.ReturnValue = strRetValue;
            lstErr.Add(objErrorHandlerClass);
            return(strRetValue);
        }
Example #4
0
        public ICollection <ErrorHandlerClass> SavePromotionEarningDetails(PromotionEarningDetails objPromotionEarningDetails)
        {
            List <ErrorHandlerClass> lstErr = new List <ErrorHandlerClass>();
            DataAccess da          = new DataAccess();
            string     strretValue = "";

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();

                if (blnIsPromotionEarningDetailsExist(objPromotionEarningDetails.EmployeePromotionNo, objPromotionEarningDetails.EmployeeId, objPromotionEarningDetails.ItemNo) == false)
                {
                    strretValue = InsertPromotionEarningDetails(objPromotionEarningDetails, da, lstErr);

                    if (strretValue != "")
                    {
                        if (blnIsEmployeeEarningDetailsExist(objPromotionEarningDetails.EmployeeId, objPromotionEarningDetails.ItemNo) == true)
                        {
                            UpdateEmployeePromotionEarningDetails(objPromotionEarningDetails, da, lstErr);
                        }
                        else
                        {
                            InsertEmployeePromotionEarningDetails(objPromotionEarningDetails, da, lstErr);
                        }
                    }

                    foreach (ErrorHandlerClass objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                    da.COMMIT_TRANSACTION();
                }
                else
                {
                    UpdatePromotionEarningDetails(objPromotionEarningDetails, da, lstErr);
                    foreach (ErrorHandlerClass objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                    da.COMMIT_TRANSACTION();
                }
            }
            catch (Exception ex)
            {
                if (da != null)
                {
                    da.ROLLBACK_TRANSACTION();
                }
                objErrorHandlerClass.Type      = ErrorConstant.strAboartType;
                objErrorHandlerClass.MsgId     = 0;
                objErrorHandlerClass.Message   = ex.Message.ToString();
                objErrorHandlerClass.RowNo     = 0;
                objErrorHandlerClass.FieldName = "";
                objErrorHandlerClass.LogCode   = "";
                lstErr.Add(objErrorHandlerClass);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(lstErr);
        }