public void SaveCallInvoiceDetail(CallInvoiceDetail argCallInvoiceDetail, DataAccess da, List <ErrorHandler> lstErr)
 {
     try
     {
         if (blnIsCallInvoiceDetailExists(argCallInvoiceDetail.CallCode, argCallInvoiceDetail.CallItemNo, argCallInvoiceDetail.RepairProcDocCode, argCallInvoiceDetail.ClientCode, da) == false)
         {
             InsertCallInvoiceDetail(argCallInvoiceDetail, da, lstErr);
         }
         else
         {
             UpdateCallInvoiceDetail(argCallInvoiceDetail, da, lstErr);
         }
     }
     catch (Exception ex)
     {
         objErrorHandler.Type       = ErrorConstant.strAboartType;
         objErrorHandler.MsgId      = 0;
         objErrorHandler.Module     = ErrorConstant.strInsertModule;
         objErrorHandler.ModulePart = ErrorConstant.strDetailModule;
         objErrorHandler.Message    = ex.Message.ToString();
         objErrorHandler.RowNo      = 0;
         objErrorHandler.FieldName  = "";
         objErrorHandler.LogCode    = "";
         lstErr.Add(objErrorHandler);
     }
 }
        private CallInvoiceDetail objCreateCallInvoiceDetail(DataRow dr)
        {
            CallInvoiceDetail tCallInvoiceDetail = new CallInvoiceDetail();

            tCallInvoiceDetail.SetObjectInfo(dr);

            return(tCallInvoiceDetail);
        }
        public void InsertCallInvoiceDetail(CallInvoiceDetail argCallInvoiceDetail, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[23];
            param[0]  = new SqlParameter("@CallCode", argCallInvoiceDetail.CallCode);
            param[1]  = new SqlParameter("@CallItemNo", argCallInvoiceDetail.CallItemNo);
            param[2]  = new SqlParameter("@RepairProcDocCode", argCallInvoiceDetail.RepairProcDocCode);
            param[3]  = new SqlParameter("@PartsCost", argCallInvoiceDetail.PartsCost);
            param[4]  = new SqlParameter("@LabourCost", argCallInvoiceDetail.LabourCost);
            param[5]  = new SqlParameter("@ShippingCost", argCallInvoiceDetail.ShippingCost);
            param[6]  = new SqlParameter("@HandlingCost", argCallInvoiceDetail.HandlingCost);
            param[7]  = new SqlParameter("@TravelCost", argCallInvoiceDetail.TravelCost);
            param[8]  = new SqlParameter("@SubTotal", argCallInvoiceDetail.SubTotal);
            param[9]  = new SqlParameter("@SalesVatPer", argCallInvoiceDetail.SalesVatPer);
            param[10] = new SqlParameter("@SalesVatAmt", argCallInvoiceDetail.SalesVatAmt);
            param[11] = new SqlParameter("@ServiceTaxPer", argCallInvoiceDetail.ServiceTaxPer);
            param[12] = new SqlParameter("@ServiceTaxAmt", argCallInvoiceDetail.ServiceTaxAmt);
            param[13] = new SqlParameter("@NetAmt", argCallInvoiceDetail.NetAmt);
            param[14] = new SqlParameter("@IsPaid", argCallInvoiceDetail.IsPaid);
            param[15] = new SqlParameter("@IsExempted", argCallInvoiceDetail.IsExempted);
            param[16] = new SqlParameter("@PartnerCode", argCallInvoiceDetail.PartnerCode);
            param[17] = new SqlParameter("@ClientCode", argCallInvoiceDetail.ClientCode);
            param[18] = new SqlParameter("@CreatedBy", argCallInvoiceDetail.CreatedBy);
            param[19] = new SqlParameter("@ModifiedBy", argCallInvoiceDetail.ModifiedBy);

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

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

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

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


            string strMessage  = Convert.ToString(param[21].Value);
            string strType     = Convert.ToString(param[20].Value);
            string strRetValue = Convert.ToString(param[22].Value);


            objErrorHandler.Type       = strType;
            objErrorHandler.MsgId      = 0;
            objErrorHandler.Module     = ErrorConstant.strInsertModule;
            objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
            objErrorHandler.Message    = strMessage.ToString();
            objErrorHandler.RowNo      = 0;
            objErrorHandler.FieldName  = "";
            objErrorHandler.LogCode    = "";
            lstErr.Add(objErrorHandler);
        }
        public CallInvoiceDetail objGetCallInvoiceDetail(string argCallCode, int argCallItemNo, string argRepairProcDocCode, string argClientCode)
        {
            CallInvoiceDetail argCallInvoiceDetail = new CallInvoiceDetail();
            DataSet           DataSetToFill        = new DataSet();

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

            if (argCallItemNo <= 0)
            {
                goto ErrorHandlers;
            }

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

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

            DataSetToFill = this.GetCallInvoiceDetail(argCallCode, argCallItemNo, argRepairProcDocCode, argClientCode);

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

            argCallInvoiceDetail = this.objCreateCallInvoiceDetail((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argCallInvoiceDetail);
        }
        public ICollection <CallInvoiceDetail> colGetCallInvoiceDetail(string argCallCode, int argCallItemNo, string argRepairProcDocCode, string argClientCode)
        {
            List <CallInvoiceDetail> lst         = new List <CallInvoiceDetail>();
            DataSet           DataSetToFill      = new DataSet();
            CallInvoiceDetail tCallInvoiceDetail = new CallInvoiceDetail();

            DataSetToFill = this.GetCallInvoiceDetail(argCallCode, argCallItemNo, argRepairProcDocCode, argClientCode);

            if (DataSetToFill != null)
            {
                foreach (DataRow dr in DataSetToFill.Tables[0].Rows)
                {
                    lst.Add(objCreateCallInvoiceDetail(dr));
                }
            }
            goto Finish;

Finish:
            DataSetToFill = null;


            return(lst);
        }
        public ICollection <ErrorHandler> SaveCallInvoiceDetail(CallInvoiceDetail argCallInvoiceDetail)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            try
            {
                if (blnIsCallInvoiceDetailExists(argCallInvoiceDetail.CallCode, argCallInvoiceDetail.CallItemNo, argCallInvoiceDetail.RepairProcDocCode, argCallInvoiceDetail.ClientCode) == false)
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    InsertCallInvoiceDetail(argCallInvoiceDetail, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                }
                else
                {
                    da.Open_Connection();
                    da.BEGIN_TRANSACTION();
                    UpdateCallInvoiceDetail(argCallInvoiceDetail, da, lstErr);
                    foreach (ErrorHandler objerr in lstErr)
                    {
                        if (objerr.Type == "E")
                        {
                            da.ROLLBACK_TRANSACTION();
                            return(lstErr);
                        }
                    }
                }
                da.COMMIT_TRANSACTION();
            }
            catch (Exception ex)
            {
                if (da != null)
                {
                    da.ROLLBACK_TRANSACTION();
                }
                objErrorHandler.Type       = ErrorConstant.strAboartType;
                objErrorHandler.MsgId      = 0;
                objErrorHandler.Module     = ErrorConstant.strInsertModule;
                objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
                objErrorHandler.Message    = ex.Message.ToString();
                objErrorHandler.RowNo      = 0;
                objErrorHandler.FieldName  = "";
                objErrorHandler.LogCode    = "";
                lstErr.Add(objErrorHandler);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(lstErr);
        }