Ejemplo n.º 1
0
        //public ICollection<ErrorHandler> SaveBillingPartner(BillingPartner argBillingPartner)
        //{
        //    List<ErrorHandler> lstErr = new List<ErrorHandler>();
        //    DataAccess da = new DataAccess();
        //    try
        //    {
        //        if (blnIsBillingPartnerExists(argBillingPartner.BillingDocCode, argBillingPartner.PFunctionCode, argBillingPartner.ClientCode) == false)
        //        {

        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            InsertBillingPartner(argBillingPartner, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }
        //            da.COMMIT_TRANSACTION();
        //        }
        //        else
        //        {
        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            UpdateBillingPartner(argBillingPartner, 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;
        //}

        public void SaveBillingPartner(BillingPartner argBillingPartner, DataAccess da, List <ErrorHandler> lstErr)
        {
            try
            {
                if (blnIsBillingPartnerExists(argBillingPartner.BillingDocCode.Trim(), argBillingPartner.PFunctionCode.Trim(), argBillingPartner.ClientCode.Trim(), da) == false)
                {
                    InsertBillingPartner(argBillingPartner, da, lstErr);
                }
                else
                {
                    UpdateBillingPartner(argBillingPartner, da, lstErr);
                }
            }
            catch (Exception ex)
            {
                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);
            }
        }
Ejemplo n.º 2
0
        private BillingPartner objCreateBillingPartner(DataRow dr)
        {
            BillingPartner tBillingPartner = new BillingPartner();

            tBillingPartner.SetObjectInfo(dr);

            return(tBillingPartner);
        }
Ejemplo n.º 3
0
        public void InsertBillingPartner(BillingPartner argBillingPartner, DataAccess da, List <ErrorHandler> lstErr)
        {
            SqlParameter[] param = new SqlParameter[10];
            param[0] = new SqlParameter("@BillingDocCode", argBillingPartner.BillingDocCode);
            param[1] = new SqlParameter("@PFunctionCode", argBillingPartner.PFunctionCode);
            param[2] = new SqlParameter("@PartnerType", argBillingPartner.PartnerType);
            param[3] = new SqlParameter("@CustomerCode", argBillingPartner.CustomerCode);
            param[4] = new SqlParameter("@ClientCode", argBillingPartner.ClientCode);
            param[5] = new SqlParameter("@CreatedBy", argBillingPartner.CreatedBy);
            param[6] = new SqlParameter("@ModifiedBy", argBillingPartner.ModifiedBy);


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

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

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

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


            string strMessage  = Convert.ToString(param[8].Value);
            string strType     = Convert.ToString(param[7].Value);
            string strRetValue = Convert.ToString(param[9].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     = "";
            objErrorHandler.ReturnValue = strRetValue;
            lstErr.Add(objErrorHandler);
        }
Ejemplo n.º 4
0
        public BillingPartner objGetBillingPartner(string argBillingDocCode, string argPFunctionCode, string argClientCode)
        {
            BillingPartner argBillingPartner = new BillingPartner();
            DataSet        DataSetToFill     = new DataSet();

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

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

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

            DataSetToFill = this.GetBillingPartner(argBillingDocCode, argPFunctionCode, argClientCode);

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

            argBillingPartner = this.objCreateBillingPartner((DataRow)DataSetToFill.Tables[0].Rows[0]);

            goto Finish;

ErrorHandlers:

Finish:
            DataSetToFill = null;


            return(argBillingPartner);
        }
Ejemplo n.º 5
0
        public ICollection <BillingPartner> colGetBillingPartner(string argBillingDocCode, string argClientCode)
        {
            List <BillingPartner> lst      = new List <BillingPartner>();
            DataSet        DataSetToFill   = new DataSet();
            BillingPartner tBillingPartner = new BillingPartner();

            DataSetToFill = this.GetBillingPartner(argBillingDocCode, argClientCode);

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

Finish:
            DataSetToFill = null;


            return(lst);
        }
Ejemplo n.º 6
0
        //public ICollection<ErrorHandler> SaveBillingMaster(BillingMaster argBillingMaster)
        //{
        //    List<ErrorHandler> lstErr = new List<ErrorHandler>();
        //    DataAccess da = new DataAccess();
        //    try
        //    {
        //        if (blnIsBillingMasterExists(argBillingMaster.BillingDocCode, argBillingMaster.ClientCode) == false)
        //        {

        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            InsertBillingMaster(argBillingMaster, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }
        //            da.COMMIT_TRANSACTION();
        //        }
        //        else
        //        {
        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            UpdateBillingMaster(argBillingMaster, 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;
        //}

        public ICollection <ErrorHandler> SaveBillingMaster(BillingMaster argBillingMaster, DataTable dtBillingPartner, ICollection <BillingDetail> colBillingDetail)
        {
            List <ErrorHandler> lstErr = new List <ErrorHandler>();
            DataAccess          da     = new DataAccess();

            string strretValue = "";

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

                if (blnIsBillingMasterExists(argBillingMaster.BillingDocCode, argBillingMaster.ClientCode, da) == false)
                {
                    strretValue = InsertBillingMaster(argBillingMaster, da, lstErr);
                }
                else
                {
                    strretValue = UpdateBillingMaster(argBillingMaster, da, lstErr);
                }

                foreach (ErrorHandler objerr in lstErr)
                {
                    if (objerr.Type == "E")
                    {
                        da.ROLLBACK_TRANSACTION();
                        return(lstErr);
                    }

                    if (objerr.Type == "A")
                    {
                        da.ROLLBACK_TRANSACTION();
                        return(lstErr);
                    }
                }

                if (strretValue != "")
                {
                    if (dtBillingPartner.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtBillingPartner.Rows)
                        {
                            if (Convert.ToInt32(dr["IsDeleted"]) == 0)
                            {
                                BillingPartner objBillingPartner = new BillingPartner();

                                objBillingPartner.BillingDocCode = strretValue.Trim();
                                objBillingPartner.PFunctionCode  = Convert.ToString(dr["PFunctionCode"]).Trim();
                                objBillingPartner.CustomerCode   = Convert.ToString(dr["CustomerCode"]).Trim();
                                objBillingPartner.PartnerType    = Convert.ToString(dr["PartnerType"]).Trim();
                                objBillingPartner.ClientCode     = Convert.ToString(dr["ClientCode"]).Trim();
                                objBillingPartner.CreatedBy      = Convert.ToString(dr["CreatedBy"]).Trim();
                                objBillingPartner.ModifiedBy     = Convert.ToString(dr["ModifiedBy"]).Trim();

                                objBillingPartnerManager.SaveBillingPartner(objBillingPartner, da, lstErr);
                            }
                            else
                            {
                                objBillingPartnerManager.DeleteBillingPartner(strretValue.Trim(), Convert.ToString(dr["PFunctionCode"]).Trim(), Convert.ToString(dr["ClientCode"]).Trim(), 1, da, lstErr);
                            }
                        }

                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }

                            if (objerr.Type == "A")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }
                        }
                    }

                    if (colBillingDetail.Count > 0)
                    {
                        foreach (BillingDetail argBillingDetail in colBillingDetail)
                        {
                            argBillingDetail.BillingDocCode = Convert.ToString(strretValue);
                            if (argBillingDetail.IsDeleted == 0)
                            {
                                objBillingDetailManager.SaveBillingDetail(argBillingDetail, da, lstErr);
                            }
                            else
                            {
                                objBillingDetailManager.DeleteBillingDetail(argBillingDetail.BillingDocCode, argBillingDetail.ItemNo, 1, argBillingDetail.ClientCode, da, lstErr);
                            }
                        }

                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                return(lstErr);
                            }

                            if (objerr.Type == "A")
                            {
                                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);
        }