public PromotionDeductionDetails objGetPromotionDeductionDetails(string EmployeeId)
        {
            PromotionDeductionDetails argPromotionDeductionDetails = new PromotionDeductionDetails();
            DataSet DataSetToFill = new DataSet();

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

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

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

            argPromotionDeductionDetails = this.objCretePromotionDeductionDetails((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;

            return(argPromotionDeductionDetails);
        }
        private PromotionDeductionDetails objCretePromotionDeductionDetails(DataRow dr)
        {
            PromotionDeductionDetails tPromotionDeductionDetails = new PromotionDeductionDetails();

            tPromotionDeductionDetails.SetObjectInfo(dr);

            return(tPromotionDeductionDetails);
        }
        public string InsertPromotionDeductionDetails(PromotionDeductionDetails argPromotionDeductionDetails, DataAccess da, List <ErrorHandlerClass> lstErr)
        {
            da.Open_Connection();

            SqlParameter[] param = new SqlParameter[18];
            param[0] = new SqlParameter("@EmployeeId", argPromotionDeductionDetails.EmployeeId);
            param[1] = new SqlParameter("@Deductions", argPromotionDeductionDetails.Deductions);
            param[2] = new SqlParameter("@DeductionPercetage", argPromotionDeductionDetails.DeductionPercetage);
            param[3] = new SqlParameter("@DeductionAmount", argPromotionDeductionDetails.DeductionAmount);
            param[4] = new SqlParameter("@DeductionCalcOn", argPromotionDeductionDetails.DeductionCalcOn);
            param[5] = new SqlParameter("@DeductionPayMode", argPromotionDeductionDetails.DeductionPayMode);
            param[6] = new SqlParameter("@DeductionLimit", argPromotionDeductionDetails.DeductionLimit);

            param[7]  = new SqlParameter("@CreatedBy", argPromotionDeductionDetails.CreatedBy);
            param[8]  = new SqlParameter("@ModifiedBy", argPromotionDeductionDetails.ModifiedBy);
            param[9]  = new SqlParameter("@ItemNo", argPromotionDeductionDetails.ItemNo);
            param[10] = new SqlParameter("@LimitAmount", argPromotionDeductionDetails.LimitAmount);
            param[11] = new SqlParameter("@NewDeductionAmount", argPromotionDeductionDetails.NewDeductionAmount);
            param[12] = new SqlParameter("@NewLimitAmount", argPromotionDeductionDetails.NewLimitAmount);
            param[13] = new SqlParameter("@NewDeductionLimit", argPromotionDeductionDetails.NewDeductionLimit);
            param[14] = new SqlParameter("@EmployeePromotionNo", argPromotionDeductionDetails.EmployeePromotionNo);

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

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

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

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

            string strMessage  = Convert.ToString(param[16].Value);
            string strType     = Convert.ToString(param[15].Value);
            string strRetValue = Convert.ToString(param[17].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);
        }
        public ICollection <ErrorHandlerClass> SavePromotionDeductionDetails(PromotionDeductionDetails objPromotionDeductionDetails)
        {
            List <ErrorHandlerClass> lstErr = new List <ErrorHandlerClass>();
            DataAccess da = new DataAccess();

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();
                string strretValue = "";
                if (blnIsPromotionDeductionDetailsExist(objPromotionDeductionDetails.EmployeePromotionNo, objPromotionDeductionDetails.EmployeeId, objPromotionDeductionDetails.ItemNo) == false)
                {
                    strretValue = InsertPromotionDeductionDetails(objPromotionDeductionDetails, da, lstErr);

                    if (strretValue != "")
                    {
                        if (blnIsEmployeeDeductionDetailsExist(objPromotionDeductionDetails.EmployeeId, objPromotionDeductionDetails.ItemNo) == true)
                        {
                            UpdateEmployeePromotionDeductionDetails(objPromotionDeductionDetails, da, lstErr);
                        }
                        else
                        {
                            InsertEmployeePromotionDeductionDetails(objPromotionDeductionDetails, da, lstErr);
                        }
                    }

                    foreach (ErrorHandlerClass objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                    da.COMMIT_TRANSACTION();
                }
                else
                {
                    //UpdatePromotionDeductionDetails(objPromotionDeductionDetails, 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);
        }