예제 #1
0
 ///<summary>Inserts one ClaimPayment into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ClaimPayment claimPayment,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         claimPayment.ClaimPaymentNum=ReplicationServers.GetKey("claimpayment","ClaimPaymentNum");
     }
     string command="INSERT INTO claimpayment (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ClaimPaymentNum,";
     }
     command+="CheckDate,CheckAmt,CheckNum,BankBranch,Note,ClinicNum,DepositNum,CarrierName,DateIssued,IsPartial) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(claimPayment.ClaimPaymentNum)+",";
     }
     command+=
              POut.Date  (claimPayment.CheckDate)+","
         +"'"+POut.Double(claimPayment.CheckAmt)+"',"
         +"'"+POut.String(claimPayment.CheckNum)+"',"
         +"'"+POut.String(claimPayment.BankBranch)+"',"
         +"'"+POut.String(claimPayment.Note)+"',"
         +    POut.Long  (claimPayment.ClinicNum)+","
         +    POut.Long  (claimPayment.DepositNum)+","
         +"'"+POut.String(claimPayment.CarrierName)+"',"
         +    POut.Date  (claimPayment.DateIssued)+","
         +    POut.Bool  (claimPayment.IsPartial)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         claimPayment.ClaimPaymentNum=Db.NonQ(command,true);
     }
     return claimPayment.ClaimPaymentNum;
 }
        private void SendNotification(Guid batchId)
        {
            List <ClaimPayment> claimPaymentList = ClaimPayment.GetClaimPaymentNotificationListByBatchId(batchId);

            foreach (ClaimPayment claimPayment in claimPaymentList)
            {
                try
                {
                    if (IsValidEmail(claimPayment.PaidEmail) == true)
                    {
                        MailMessage mailMessage = new MailMessage(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), claimPayment.PaidEmail /*"*****@*****.**"*/);

                        mailMessage.Subject    = claimPayment.EmailSubject;
                        mailMessage.Body       = claimPayment.EmailBody;
                        mailMessage.IsBodyHtml = true;

                        mailMessage.Bcc.Add(new MailAddress(ConfigurationManager.AppSettings["claimPaymentCCEmailAddress"].ToString()));

                        SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mailRelay"].ToString());
                        smtpClient.Port        = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
                        smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), ConfigurationManager.AppSettings["password"].ToString());
                        smtpClient.EnableSsl   = true;
                        smtpClient.Send(mailMessage);
                    }
                }
                catch (Exception ex)
                {
                    LabelError.Text    = "";
                    LabelError.Text   += ex.Message /* + " - " + ex.InnerException.ToString()*/;
                    PanelError.Visible = true;
                }
            }
        }
예제 #3
0
 ///<summary>Inserts one ClaimPayment into the database.  Returns the new priKey.</summary>
 internal static long Insert(ClaimPayment claimPayment)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         claimPayment.ClaimPaymentNum=DbHelper.GetNextOracleKey("claimpayment","ClaimPaymentNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(claimPayment,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     claimPayment.ClaimPaymentNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(claimPayment,false);
     }
 }
예제 #4
0
        private void butRun_Click(object sender, EventArgs e)
        {
            List <ClaimPaySplit> splits = Claims.GetInsPayNotAttachedForFixTool();

            if (splits.Count == 0)
            {
                MsgBox.Show(this, "There are currently no insurance payments that are not attached to an insurance check.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            for (int i = 0; i < splits.Count; i++)
            {
                Claim        claim = Claims.GetClaim(splits[i].ClaimNum);
                ClaimPayment cp    = new ClaimPayment();
                cp.CheckDate   = claim.DateService;
                cp.CheckAmt    = splits[i].InsPayAmt;
                cp.ClinicNum   = claim.ClinicNum;
                cp.CarrierName = splits[i].Carrier;
                ClaimPayments.Insert(cp);
                List <ClaimProc> claimP = ClaimProcs.RefreshForClaim(splits[i].ClaimNum);
                for (int j = 0; j < claimP.Count; j++)
                {
                    claimP[j].DateCP          = claim.DateService;
                    claimP[j].ClaimPaymentNum = cp.ClaimPaymentNum;
                    ClaimProcs.Update(claimP[j]);
                }
            }
            Cursor = Cursors.Default;
            MessageBox.Show(Lan.g(this, "Insurance checks created: ") + splits.Count);
        }
예제 #5
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.InsPayCreate))             //date not checked here, but it will be checked when saving the check to prevent backdating
            {
                return;
            }
            ClaimPayment claimPayment = new ClaimPayment();

            claimPayment.CheckDate = DateTime.Now;
            claimPayment.IsPartial = true;
            FormClaimPayEdit FormCPE = new FormClaimPayEdit(claimPayment);

            FormCPE.IsNew = true;
            FormCPE.ShowDialog();
            if (FormCPE.DialogResult != DialogResult.OK)
            {
                return;
            }
            FormClaimPayBatch FormCPB = new FormClaimPayBatch(claimPayment);

            //FormCPB.IsFromClaim=IsFromClaim;
            FormCPB.ShowDialog();
            if (FormCPB.GotoClaimNum != 0)
            {
                GotoClaimNum = FormCPB.GotoClaimNum;
                GotoPatNum   = FormCPB.GotoPatNum;
                Close();
            }
            else
            {
                FillGrid();
            }
        }
예제 #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ClaimPayment> TableToList(DataTable table)
        {
            List <ClaimPayment> retVal = new List <ClaimPayment>();
            ClaimPayment        claimPayment;

            foreach (DataRow row in table.Rows)
            {
                claimPayment = new ClaimPayment();
                claimPayment.ClaimPaymentNum = PIn.Long(row["ClaimPaymentNum"].ToString());
                claimPayment.CheckDate       = PIn.Date(row["CheckDate"].ToString());
                claimPayment.CheckAmt        = PIn.Double(row["CheckAmt"].ToString());
                claimPayment.CheckNum        = PIn.String(row["CheckNum"].ToString());
                claimPayment.BankBranch      = PIn.String(row["BankBranch"].ToString());
                claimPayment.Note            = PIn.String(row["Note"].ToString());
                claimPayment.ClinicNum       = PIn.Long(row["ClinicNum"].ToString());
                claimPayment.DepositNum      = PIn.Long(row["DepositNum"].ToString());
                claimPayment.CarrierName     = PIn.String(row["CarrierName"].ToString());
                claimPayment.DateIssued      = PIn.Date(row["DateIssued"].ToString());
                claimPayment.IsPartial       = PIn.Bool(row["IsPartial"].ToString());
                claimPayment.PayType         = PIn.Long(row["PayType"].ToString());
                claimPayment.SecUserNumEntry = PIn.Long(row["SecUserNumEntry"].ToString());
                claimPayment.SecDateEntry    = PIn.Date(row["SecDateEntry"].ToString());
                claimPayment.SecDateTEdit    = PIn.DateT(row["SecDateTEdit"].ToString());
                claimPayment.PayGroup        = PIn.Long(row["PayGroup"].ToString());
                retVal.Add(claimPayment);
            }
            return(retVal);
        }
예제 #7
0
        ///<summary>If trying to change the amount and attached to a deposit, it will throw an error, so surround with try catch.</summary>
        public static void Update(ClaimPayment cp)
        {
            string command = "SELECT DepositNum,CheckAmt FROM claimpayment "
                             + "WHERE ClaimPaymentNum=" + POut.PInt(cp.ClaimPaymentNum);
            DataTable table = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            if (table.Rows[0][0].ToString() != "0" &&      //if claimpayment is already attached to a deposit
                PIn.PDouble(table.Rows[0][1].ToString()) != cp.CheckAmt)                 //and checkAmt changes
            {
                throw new ApplicationException(Lan.g("ClaimPayments", "Not allowed to change the amount on checks attached to deposits."));
            }
            command = "UPDATE claimpayment SET "
                      + "checkdate = " + POut.PDate(cp.CheckDate) + " "
                      + ",checkamt = '" + POut.PDouble(cp.CheckAmt) + "' "
                      + ",checknum = '" + POut.PString(cp.CheckNum) + "' "
                      + ",bankbranch = '" + POut.PString(cp.BankBranch) + "' "
                      + ",note = '" + POut.PString(cp.Note) + "' "
                      + ",ClinicNum = '" + POut.PInt(cp.ClinicNum) + "' "
                      + ",DepositNum = '" + POut.PInt(cp.DepositNum) + "' "
                      + ",CarrierName = '" + POut.PString(cp.CarrierName) + "' "
                      + "WHERE ClaimPaymentnum = '" + POut.PInt(cp.ClaimPaymentNum) + "'";
            //MessageBox.Show(string command);
            General.NonQ(command);
        }
예제 #8
0
 ///<summary></summary>
 public FormClaimPayEditOld(ClaimPayment claimPaymentCur)
 {
     InitializeComponent();            // Required for Windows Form Designer support
     ClaimPaymentCur = claimPaymentCur;
     splits          = new List <ClaimPaySplit>();
     Lan.F(this);
 }
예제 #9
0
        private void ClaimPaymentNotification(int claimId)
        {
            try
            {
                ClaimPayment claimPayment = ClaimPayment.GetClaimPaymentValidationNotification(claimId);

                if (claimPayment.EmailSubject.Length > 0)
                {
                    MailMessage mailMessage = new MailMessage(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), ConfigurationManager.AppSettings["claimNotificationEmailAddress"].ToString() /*"*****@*****.**"*/);

                    mailMessage.Subject    = claimPayment.EmailSubject;
                    mailMessage.Body       = claimPayment.EmailBody;
                    mailMessage.IsBodyHtml = true;

                    SmtpClient smtpClient = new SmtpClient(ConfigurationManager.AppSettings["mailRelay"].ToString());
                    smtpClient.Port        = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
                    smtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["administrationEmailAddress"].ToString(), ConfigurationManager.AppSettings["password"].ToString());
                    smtpClient.EnableSsl   = true;
                    smtpClient.Send(mailMessage);
                }
            }
            catch (Exception ex)
            {
                LabelError.Text    = "";
                LabelError.Text   += ex.Message /* + " - " + ex.InnerException.ToString()*/;
                PanelError.Visible = true;
            }
        }
예제 #10
0
 ///<summary>Inserts one ClaimPayment into the database.  Returns the new priKey.</summary>
 internal static long Insert(ClaimPayment claimPayment)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         claimPayment.ClaimPaymentNum = DbHelper.GetNextOracleKey("claimpayment", "ClaimPaymentNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(claimPayment, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     claimPayment.ClaimPaymentNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(claimPayment, false));
     }
 }
        private void BindGridViewResult()
        {
            string claimMonth = "";

            for (int i = 0; i < ListBoxClaimMonth.Items.Count; i++)
            {
                if (ListBoxClaimMonth.Items[i].Selected == true)
                {
                    if (ListBoxClaimMonth.Items[i].Text == "ALL")
                    {
                        for (int j = 0; j < ListBoxClaimMonth.Items.Count; j++)
                        {
                            claimMonth += ListBoxClaimMonth.Items[j].Text + ",";
                        }
                    }
                    else
                    {
                        claimMonth += ListBoxClaimMonth.Items[i].Text;
                    }
                }
            }

            PanelErrorSpace.Visible = false;
            PanelSaveSpace.Visible  = false;

            GridViewResult.DataSource = ClaimPayment.GetClaimPaymentListByClaimMonthAndLocationIdNonDairy(claimMonth, Convert.ToInt32(DropDownListLocation.SelectedValue), Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).AccountId, (RadioButtonPaid.Checked) ? 1 : 0);
            GridViewResult.DataBind();
            ButtonSaveList.Visible   = GridViewResult.Rows.Count > 0 && !RadioButtonPaid.Checked;
            ButtonFNBPreview.Visible = GridViewResult.Rows.Count > 0 && !RadioButtonPaid.Checked;
        }
예제 #12
0
 ///<summary></summary>
 public FormClaimPayEdit(ClaimPayment claimPaymentCur)
 {
     InitializeComponent();            // Required for Windows Form Designer support
     ClaimPaymentCur        = claimPaymentCur;
     tb2.CellClicked       += new OpenDental.ContrTable.CellEventHandler(tb2_CellClicked);
     tb2.CellDoubleClicked += new OpenDental.ContrTable.CellEventHandler(tb2_CellDoubleClicked);
     Lan.F(this);
 }
예제 #13
0
 ///<summary>Returns true if Update(ClaimPayment,ClaimPayment) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(ClaimPayment claimPayment, ClaimPayment oldClaimPayment)
 {
     if (claimPayment.CheckDate.Date != oldClaimPayment.CheckDate.Date)
     {
         return(true);
     }
     if (claimPayment.CheckAmt != oldClaimPayment.CheckAmt)
     {
         return(true);
     }
     if (claimPayment.CheckNum != oldClaimPayment.CheckNum)
     {
         return(true);
     }
     if (claimPayment.BankBranch != oldClaimPayment.BankBranch)
     {
         return(true);
     }
     if (claimPayment.Note != oldClaimPayment.Note)
     {
         return(true);
     }
     if (claimPayment.ClinicNum != oldClaimPayment.ClinicNum)
     {
         return(true);
     }
     if (claimPayment.DepositNum != oldClaimPayment.DepositNum)
     {
         return(true);
     }
     if (claimPayment.CarrierName != oldClaimPayment.CarrierName)
     {
         return(true);
     }
     if (claimPayment.DateIssued.Date != oldClaimPayment.DateIssued.Date)
     {
         return(true);
     }
     if (claimPayment.IsPartial != oldClaimPayment.IsPartial)
     {
         return(true);
     }
     if (claimPayment.PayType != oldClaimPayment.PayType)
     {
         return(true);
     }
     //SecUserNumEntry excluded from update
     //SecDateEntry not allowed to change
     //SecDateTEdit can only be set by MySQL
     if (claimPayment.PayGroup != oldClaimPayment.PayGroup)
     {
         return(true);
     }
     return(false);
 }
예제 #14
0
        private void butRun_Click(object sender, EventArgs e)
        {
            List <ClaimPaySplit> splits = Claims.GetInsPayNotAttachedForFixTool();

            if (splits.Count == 0)
            {
                MsgBox.Show(this, "There are currently no insurance payments that are not attached to an insurance check.");
                DialogResult = DialogResult.OK;              //Close the window because there is nothing else to do
                return;
            }
            Cursor = Cursors.WaitCursor;
            string   invalidClaimDate = "";
            DateTime curDate          = MiscData.GetNowDateTime().Date;

            for (int i = 0; i < splits.Count; i++)
            {
                Claim claim = Claims.GetClaim(splits[i].ClaimNum);
                if (claim == null)
                {
                    continue;
                }
                if (claim.DateReceived.Date > curDate && !PrefC.GetBool(PrefName.AllowFutureInsPayments) && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
                {
                    invalidClaimDate += "\r\n" + Lan.g(this, "PatNum") + " " + claim.PatNum + ", " + claim.DateService.ToShortDateString();
                    continue;
                }
                ClaimPayment cp = new ClaimPayment();
                cp.CheckDate   = claim.DateReceived;
                cp.CheckAmt    = splits[i].InsPayAmt;
                cp.ClinicNum   = claim.ClinicNum;
                cp.CarrierName = splits[i].Carrier;
                cp.PayType     = Defs.GetFirstForCategory(DefCat.InsurancePaymentType, true).DefNum;
                ClaimPayments.Insert(cp);
                List <ClaimProc> claimP = ClaimProcs.RefreshForClaim(splits[i].ClaimNum);
                for (int j = 0; j < claimP.Count; j++)
                {
                    if (claimP[j].ClaimPaymentNum != 0 || claimP[j].InsPayAmt == 0) //If claimpayment already attached to claimproc or ins didn't pay.
                    {
                        continue;                                                   //Do not change
                    }
                    claimP[j].DateCP          = claim.DateReceived;
                    claimP[j].ClaimPaymentNum = cp.ClaimPaymentNum;
                    ClaimProcs.Update(claimP[j]);
                }
            }
            Cursor = Cursors.Default;
            if (invalidClaimDate != "")
            {
                invalidClaimDate = "\r\n" + Lan.g(this, "Cannot make future-dated insurance payments for these claims:") + invalidClaimDate;
            }
            MsgBoxCopyPaste messageBox = new MsgBoxCopyPaste(Lan.g(this, "Insurance checks created:") + " " + splits.Count + invalidClaimDate);

            messageBox.Show();
            DialogResult = DialogResult.OK;          //Close the window because there is nothing else to do
        }
        /// <summary>Creates a check for the claim selected. Copied logic from FormClaimEdit.cs</summary>
        private void createCheckToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.InsPayCreate))             //date not checked here, but it will be checked when saving the check to prevent backdating
            {
                return;
            }
            if (PrefC.GetBool(PrefName.ClaimPaymentBatchOnly))
            {
                //Is there a permission in the manage module that would block this behavior? Are we sending the user into a TRAP?!
                MsgBox.Show(this, "Please use Batch Insurance in Manage Module to Finalize Payments.");
                return;
            }
            RpUnfinalizedInsPay.UnfinalizedInsPay unfinalPay = (RpUnfinalizedInsPay.UnfinalizedInsPay)gridMain.ListGridRows[gridMain.SelectedIndices[0]].Tag;
            if (unfinalPay.ClaimCur == null)
            {
                MsgBox.Show(this, "Unable to find claim for this partial payment.");
                return;
            }
            List <ClaimProc> listClaimProcForClaim = ClaimProcs.RefreshForClaim(unfinalPay.ClaimCur.ClaimNum);

            if (!listClaimProcForClaim.Any(x => x.Status.In(ClaimProcs.GetInsPaidStatuses())))
            {
                MessageBox.Show(Lan.g(this, "There are no valid received payments for this claim."));
                return;
            }
            ClaimPayment claimPayment = new ClaimPayment();

            claimPayment.CheckDate = MiscData.GetNowDateTime().Date;          //Today's date for easier tracking by the office and to avoid backdating before accounting lock dates.
            claimPayment.IsPartial = true;
            claimPayment.ClinicNum = unfinalPay.ClinicCur.ClinicNum;
            Family         famCur      = Patients.GetFamily(unfinalPay.PatientCur.PatNum);
            List <InsSub>  listInsSub  = InsSubs.RefreshForFam(famCur);
            List <InsPlan> listInsPlan = InsPlans.RefreshForSubList(listInsSub);

            claimPayment.CarrierName = Carriers.GetName(InsPlans.GetPlan(unfinalPay.ClaimCur.PlanNum, listInsPlan).CarrierNum);
            ClaimPayments.Insert(claimPayment);
            double amt = ClaimProcs.AttachAllOutstandingToPayment(claimPayment.ClaimPaymentNum, PrefC.DateClaimReceivedAfter);

            claimPayment.CheckAmt = amt;
            try {
                ClaimPayments.Update(claimPayment);
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            FormClaimEdit.FormFinalizePaymentHelper(claimPayment, unfinalPay.ClaimCur, unfinalPay.PatientCur, famCur);
            LoadData();
            FillGrid();
        }
예제 #16
0
 ///<summary>Inserts one ClaimPayment into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ClaimPayment claimPayment)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(claimPayment, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             claimPayment.ClaimPaymentNum = DbHelper.GetNextOracleKey("claimpayment", "ClaimPaymentNum");                  //Cacheless method
         }
         return(InsertNoCache(claimPayment, true));
     }
 }
예제 #17
0
        private void SearchByTextBox()
        {
            bool isPaid = false;

            PanelErrorSpace.Visible = false;
            PanelSaveSpace.Visible  = false;
            //BindStore();
            BindLocation();
            ListBoxClaimMonth.Items.Clear();

            List <ClaimPayment> claimPaymentList = ClaimPayment.GetClaimPaymentListByClaimNumber(((TextBoxClaimNumber.Text.Length == 0) ? "" : TextBoxClaimNumber.Text), Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).AccountId /*, (RadioButtonPaid.Checked) ? 1 : 0*/);

            GridViewResult.DataSource = claimPaymentList;//ClaimPayment.GetClaimPaymentListByClaimNumber(((TextBoxClaimNumber.Text.Length == 0) ? "" : TextBoxClaimNumber.Text), Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).AccountId, (RadioButtonPaid.Checked) ? 1 : 0);
            GridViewResult.DataBind();

            foreach (ClaimPayment claimPayment in claimPaymentList)
            {
                if (claimPayment.ClaimValuePaid > 0)
                {
                    isPaid = true;
                }
            }

            if (isPaid)
            {
                ButtonSaveList.Visible   = false;
                ButtonFNBPreview.Visible = false;
                //ButtonSaveResend.Visible = true;
            }
            else
            {
                ButtonSaveList.Visible   = true;
                ButtonFNBPreview.Visible = true;
                //ButtonSaveResend.Visible = false;
            }

            RadioButtonPaid.Checked   = false;
            RadioButtonUnpaid.Checked = false;

            //ButtonSaveList.Visible = GridViewResult.Rows.Count > 0 && !RadioButtonPaid.Checked;
            //ButtonSaveResend.Visible = GridViewResult.Rows.Count > 0 && RadioButtonPaid.Checked;

            if (GridViewResult.Rows.Count == 0)
            {
                GridViewResult.DataBind();
            }
        }
예제 #18
0
        ///<summary>Updates one ClaimPayment in the database.</summary>
        internal static void Update(ClaimPayment claimPayment)
        {
            string command = "UPDATE claimpayment SET "
                             + "CheckDate      =  " + POut.Date(claimPayment.CheckDate) + ", "
                             + "CheckAmt       = '" + POut.Double(claimPayment.CheckAmt) + "', "
                             + "CheckNum       = '" + POut.String(claimPayment.CheckNum) + "', "
                             + "BankBranch     = '" + POut.String(claimPayment.BankBranch) + "', "
                             + "Note           = '" + POut.String(claimPayment.Note) + "', "
                             + "ClinicNum      =  " + POut.Long(claimPayment.ClinicNum) + ", "
                             + "DepositNum     =  " + POut.Long(claimPayment.DepositNum) + ", "
                             + "CarrierName    = '" + POut.String(claimPayment.CarrierName) + "', "
                             + "DateIssued     =  " + POut.Date(claimPayment.DateIssued) + ", "
                             + "IsPartial      =  " + POut.Bool(claimPayment.IsPartial) + " "
                             + "WHERE ClaimPaymentNum = " + POut.Long(claimPayment.ClaimPaymentNum);

            Db.NonQ(command);
        }
예제 #19
0
        ///<summary>Inserts one ClaimPayment into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ClaimPayment claimPayment, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO claimpayment (";

            if (!useExistingPK && isRandomKeys)
            {
                claimPayment.ClaimPaymentNum = ReplicationServers.GetKeyNoCache("claimpayment", "ClaimPaymentNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ClaimPaymentNum,";
            }
            command += "CheckDate,CheckAmt,CheckNum,BankBranch,Note,ClinicNum,DepositNum,CarrierName,DateIssued,IsPartial,PayType,SecUserNumEntry,SecDateEntry,PayGroup) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(claimPayment.ClaimPaymentNum) + ",";
            }
            command +=
                POut.Date(claimPayment.CheckDate) + ","
                + "'" + POut.Double(claimPayment.CheckAmt) + "',"
                + "'" + POut.String(claimPayment.CheckNum) + "',"
                + "'" + POut.String(claimPayment.BankBranch) + "',"
                + "'" + POut.String(claimPayment.Note) + "',"
                + POut.Long(claimPayment.ClinicNum) + ","
                + POut.Long(claimPayment.DepositNum) + ","
                + "'" + POut.String(claimPayment.CarrierName) + "',"
                + POut.Date(claimPayment.DateIssued) + ","
                + POut.Bool(claimPayment.IsPartial) + ","
                + POut.Long(claimPayment.PayType) + ","
                + POut.Long(claimPayment.SecUserNumEntry) + ","
                + DbHelper.Now() + ","
                //SecDateTEdit can only be set by MySQL
                + POut.Long(claimPayment.PayGroup) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                claimPayment.ClaimPaymentNum = Db.NonQ(command, true, "ClaimPaymentNum", "claimPayment");
            }
            return(claimPayment.ClaimPaymentNum);
        }
예제 #20
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ClaimPayment> TableToList(DataTable table){
			List<ClaimPayment> retVal=new List<ClaimPayment>();
			ClaimPayment claimPayment;
			for(int i=0;i<table.Rows.Count;i++) {
				claimPayment=new ClaimPayment();
				claimPayment.ClaimPaymentNum= PIn.Long  (table.Rows[i]["ClaimPaymentNum"].ToString());
				claimPayment.CheckDate      = PIn.Date  (table.Rows[i]["CheckDate"].ToString());
				claimPayment.CheckAmt       = PIn.Double(table.Rows[i]["CheckAmt"].ToString());
				claimPayment.CheckNum       = PIn.String(table.Rows[i]["CheckNum"].ToString());
				claimPayment.BankBranch     = PIn.String(table.Rows[i]["BankBranch"].ToString());
				claimPayment.Note           = PIn.String(table.Rows[i]["Note"].ToString());
				claimPayment.ClinicNum      = PIn.Long  (table.Rows[i]["ClinicNum"].ToString());
				claimPayment.DepositNum     = PIn.Long  (table.Rows[i]["DepositNum"].ToString());
				claimPayment.CarrierName    = PIn.String(table.Rows[i]["CarrierName"].ToString());
				claimPayment.DateIssued     = PIn.Date  (table.Rows[i]["DateIssued"].ToString());
				claimPayment.IsPartial      = PIn.Bool  (table.Rows[i]["IsPartial"].ToString());
				retVal.Add(claimPayment);
			}
			return retVal;
		}
예제 #21
0
        private static ClaimPayment[] RefreshAndFill(string command)
        {
            DataTable table = General.GetTable(command);

            ClaimPayment[] List = new ClaimPayment[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new ClaimPayment();
                List[i].ClaimPaymentNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].CheckDate       = PIn.PDate(table.Rows[i][1].ToString());
                List[i].CheckAmt        = PIn.PDouble(table.Rows[i][2].ToString());
                List[i].CheckNum        = PIn.PString(table.Rows[i][3].ToString());
                List[i].BankBranch      = PIn.PString(table.Rows[i][4].ToString());
                List[i].Note            = PIn.PString(table.Rows[i][5].ToString());
                List[i].ClinicNum       = PIn.PInt(table.Rows[i][6].ToString());
                List[i].DepositNum      = PIn.PInt(table.Rows[i][7].ToString());
                List[i].CarrierName     = PIn.PString(table.Rows[i][8].ToString());
            }
            return(List);
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                LabelError.Text         = "";
                PanelErrorSpace.Visible = false;
                bool hasError = false;
                try
                {
                    if (TextBoxExplanation.Text.Length == 0)
                    {
                        LabelError.Text         = "Explanation is required.";
                        PanelError.Visible      = true;
                        PanelErrorSpace.Visible = true;
                        hasError = true;
                        return;
                    }
                    ClaimPayment.UpdateClaimPaymentExplanationByClaimPaymentId(this.claimPaymentId, TextBoxExplanation.Text, this.Master.LoggedOnAccount);

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSaveList":
                        Response.Redirect(String.Format("ClaimPaymentEdit.aspx?ClaimNumber={0}", ClaimPayment.GetClaimPaymentByClaimPaymentId(this.claimPaymentId).ClaimNumber));
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible      = true;
                    PanelErrorSpace.Visible = true;
                }
            }
        }
예제 #23
0
        ///<summary>Updates one ClaimPayment in the database.</summary>
        public static void Update(ClaimPayment claimPayment)
        {
            string command = "UPDATE claimpayment SET "
                             + "CheckDate      =  " + POut.Date(claimPayment.CheckDate) + ", "
                             + "CheckAmt       = '" + POut.Double(claimPayment.CheckAmt) + "', "
                             + "CheckNum       = '" + POut.String(claimPayment.CheckNum) + "', "
                             + "BankBranch     = '" + POut.String(claimPayment.BankBranch) + "', "
                             + "Note           = '" + POut.String(claimPayment.Note) + "', "
                             + "ClinicNum      =  " + POut.Long(claimPayment.ClinicNum) + ", "
                             + "DepositNum     =  " + POut.Long(claimPayment.DepositNum) + ", "
                             + "CarrierName    = '" + POut.String(claimPayment.CarrierName) + "', "
                             + "DateIssued     =  " + POut.Date(claimPayment.DateIssued) + ", "
                             + "IsPartial      =  " + POut.Bool(claimPayment.IsPartial) + ", "
                             + "PayType        =  " + POut.Long(claimPayment.PayType) + ", "
                             //SecUserNumEntry excluded from update
                             //SecDateEntry not allowed to change
                             //SecDateTEdit can only be set by MySQL
                             + "PayGroup       =  " + POut.Long(claimPayment.PayGroup) + " "
                             + "WHERE ClaimPaymentNum = " + POut.Long(claimPayment.ClaimPaymentNum);

            Db.NonQ(command);
        }
예제 #24
0
        ///<summary>Inserts one ClaimPayment into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(ClaimPayment claimPayment, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                claimPayment.ClaimPaymentNum = ReplicationServers.GetKey("claimpayment", "ClaimPaymentNum");
            }
            string command = "INSERT INTO claimpayment (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ClaimPaymentNum,";
            }
            command += "CheckDate,CheckAmt,CheckNum,BankBranch,Note,ClinicNum,DepositNum,CarrierName,DateIssued,IsPartial) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(claimPayment.ClaimPaymentNum) + ",";
            }
            command +=
                POut.Date(claimPayment.CheckDate) + ","
                + "'" + POut.Double(claimPayment.CheckAmt) + "',"
                + "'" + POut.String(claimPayment.CheckNum) + "',"
                + "'" + POut.String(claimPayment.BankBranch) + "',"
                + "'" + POut.String(claimPayment.Note) + "',"
                + POut.Long(claimPayment.ClinicNum) + ","
                + POut.Long(claimPayment.DepositNum) + ","
                + "'" + POut.String(claimPayment.CarrierName) + "',"
                + POut.Date(claimPayment.DateIssued) + ","
                + POut.Bool(claimPayment.IsPartial) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                claimPayment.ClaimPaymentNum = Db.NonQ(command, true);
            }
            return(claimPayment.ClaimPaymentNum);
        }
예제 #25
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.InsPayCreate))             //date not checked here, but it will be checked when saving the check to prevent backdating
            {
                return;
            }
            ClaimPayment claimPayment = new ClaimPayment();

            claimPayment.CheckDate = DateTime.Now;
            claimPayment.IsPartial = true;
            FormClaimPayEdit FormCPE = new FormClaimPayEdit(claimPayment);

            FormCPE.IsNew = true;
            FormCPE.ShowDialog();
            if (FormCPE.DialogResult != DialogResult.OK)
            {
                return;
            }
            FormClaimPayBatch FormCPB = new FormClaimPayBatch(claimPayment, true);

            FormCPB.Show();
            FormCPB.FormClosed += FormCPB_FormClosed;
        }
예제 #26
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <ClaimPayment> TableToList(DataTable table)
        {
            List <ClaimPayment> retVal = new List <ClaimPayment>();
            ClaimPayment        claimPayment;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                claimPayment = new ClaimPayment();
                claimPayment.ClaimPaymentNum = PIn.Long(table.Rows[i]["ClaimPaymentNum"].ToString());
                claimPayment.CheckDate       = PIn.Date(table.Rows[i]["CheckDate"].ToString());
                claimPayment.CheckAmt        = PIn.Double(table.Rows[i]["CheckAmt"].ToString());
                claimPayment.CheckNum        = PIn.String(table.Rows[i]["CheckNum"].ToString());
                claimPayment.BankBranch      = PIn.String(table.Rows[i]["BankBranch"].ToString());
                claimPayment.Note            = PIn.String(table.Rows[i]["Note"].ToString());
                claimPayment.ClinicNum       = PIn.Long(table.Rows[i]["ClinicNum"].ToString());
                claimPayment.DepositNum      = PIn.Long(table.Rows[i]["DepositNum"].ToString());
                claimPayment.CarrierName     = PIn.String(table.Rows[i]["CarrierName"].ToString());
                claimPayment.DateIssued      = PIn.Date(table.Rows[i]["DateIssued"].ToString());
                claimPayment.IsPartial       = PIn.Bool(table.Rows[i]["IsPartial"].ToString());
                retVal.Add(claimPayment);
            }
            return(retVal);
        }
        protected void GridViewResult_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridViewRow currentRow = e.Row;

            if (currentRow.RowIndex == 0)
            {
                previousGridViewCurrent = (Object)currentRow.DataItem;
            }

            if (currentRow.RowIndex > 0)
            {
                ClaimPayment previousStore = (ClaimPayment)previousGridViewCurrent;
                ClaimPayment currentStore  = (ClaimPayment)currentRow.DataItem;

                if (previousStore.StoreId == currentStore.StoreId)
                {
                    currentRow.Cells[8].ForeColor = System.Drawing.Color.White;
                    currentRow.Cells[9].ForeColor = System.Drawing.Color.White;
                }

                previousGridViewCurrent = (Object)currentStore;
            }
        }
예제 #28
0
        ///<summary>Surround by try catch, because it will throw an exception if trying to delete a claimpayment attached to a deposit.</summary>
        public static void Delete(ClaimPayment cp)
        {
            string command = "SELECT DepositNum FROM claimpayment "
                             + "WHERE ClaimPaymentNum=" + POut.PInt(cp.ClaimPaymentNum);
            DataTable table = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            if (table.Rows[0][0].ToString() != "0")          //if claimpayment is already attached to a deposit
            {
                throw new ApplicationException(Lan.g("ClaimPayments", "Not allowed to delete a payment attached to a deposit."));
            }
            command = "UPDATE claimproc SET "
                      + "ClaimPaymentNum=0 "
                      + "WHERE claimpaymentNum=" + POut.PInt(cp.ClaimPaymentNum);
            //MessageBox.Show(string command);
            General.NonQ(command);
            command = "DELETE FROM claimpayment "
                      + "WHERE ClaimPaymentnum =" + POut.PInt(cp.ClaimPaymentNum);
            //MessageBox.Show(string command);
            General.NonQ(command);
        }
예제 #29
0
        ///<summary></summary>
        public static void Insert(ClaimPayment cp)
        {
            if (PrefB.RandomKeys)
            {
                cp.ClaimPaymentNum = MiscData.GetKey("claimpayment", "ClaimPaymentNum");
            }
            string command = "INSERT INTO claimpayment (";

            if (PrefB.RandomKeys)
            {
                command += "ClaimPaymentNum,";
            }
            command += "CheckDate,CheckAmt,CheckNum,"
                       + "BankBranch,Note,ClinicNum,DepositNum,CarrierName) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(cp.ClaimPaymentNum) + "', ";
            }
            command +=
                POut.PDate(cp.CheckDate) + ", "
                + "'" + POut.PDouble(cp.CheckAmt) + "', "
                + "'" + POut.PString(cp.CheckNum) + "', "
                + "'" + POut.PString(cp.BankBranch) + "', "
                + "'" + POut.PString(cp.Note) + "', "
                + "'" + POut.PInt(cp.ClinicNum) + "', "
                + "'" + POut.PInt(cp.DepositNum) + "', "
                + "'" + POut.PString(cp.CarrierName) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                cp.ClaimPaymentNum = General.NonQ(command, true);
            }
        }
예제 #30
0
        ///<summary>Updates one ClaimPayment in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(ClaimPayment claimPayment, ClaimPayment oldClaimPayment)
        {
            string command = "";

            if (claimPayment.CheckDate != oldClaimPayment.CheckDate)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CheckDate = " + POut.Date(claimPayment.CheckDate) + "";
            }
            if (claimPayment.CheckAmt != oldClaimPayment.CheckAmt)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CheckAmt = '" + POut.Double(claimPayment.CheckAmt) + "'";
            }
            if (claimPayment.CheckNum != oldClaimPayment.CheckNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CheckNum = '" + POut.String(claimPayment.CheckNum) + "'";
            }
            if (claimPayment.BankBranch != oldClaimPayment.BankBranch)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "BankBranch = '" + POut.String(claimPayment.BankBranch) + "'";
            }
            if (claimPayment.Note != oldClaimPayment.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(claimPayment.Note) + "'";
            }
            if (claimPayment.ClinicNum != oldClaimPayment.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(claimPayment.ClinicNum) + "";
            }
            if (claimPayment.DepositNum != oldClaimPayment.DepositNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DepositNum = " + POut.Long(claimPayment.DepositNum) + "";
            }
            if (claimPayment.CarrierName != oldClaimPayment.CarrierName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CarrierName = '" + POut.String(claimPayment.CarrierName) + "'";
            }
            if (claimPayment.DateIssued != oldClaimPayment.DateIssued)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateIssued = " + POut.Date(claimPayment.DateIssued) + "";
            }
            if (claimPayment.IsPartial != oldClaimPayment.IsPartial)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsPartial = " + POut.Bool(claimPayment.IsPartial) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE claimpayment SET " + command
                      + " WHERE ClaimPaymentNum = " + POut.Long(claimPayment.ClaimPaymentNum);
            Db.NonQ(command);
        }
예제 #31
0
		///<summary>Updates one ClaimPayment in the database.</summary>
		public static void Update(ClaimPayment claimPayment){
			string command="UPDATE claimpayment SET "
				+"CheckDate      =  "+POut.Date  (claimPayment.CheckDate)+", "
				+"CheckAmt       = '"+POut.Double(claimPayment.CheckAmt)+"', "
				+"CheckNum       = '"+POut.String(claimPayment.CheckNum)+"', "
				+"BankBranch     = '"+POut.String(claimPayment.BankBranch)+"', "
				+"Note           = '"+POut.String(claimPayment.Note)+"', "
				+"ClinicNum      =  "+POut.Long  (claimPayment.ClinicNum)+", "
				+"DepositNum     =  "+POut.Long  (claimPayment.DepositNum)+", "
				+"CarrierName    = '"+POut.String(claimPayment.CarrierName)+"', "
				+"DateIssued     =  "+POut.Date  (claimPayment.DateIssued)+", "
				+"IsPartial      =  "+POut.Bool  (claimPayment.IsPartial)+", "
				+"PayType        =  "+POut.Long  (claimPayment.PayType)+" "
				+"WHERE ClaimPaymentNum = "+POut.Long(claimPayment.ClaimPaymentNum);
			Db.NonQ(command);
		}
예제 #32
0
		///<summary>Updates one ClaimPayment in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(ClaimPayment claimPayment,ClaimPayment oldClaimPayment){
			string command="";
			if(claimPayment.CheckDate != oldClaimPayment.CheckDate) {
				if(command!=""){ command+=",";}
				command+="CheckDate = "+POut.Date(claimPayment.CheckDate)+"";
			}
			if(claimPayment.CheckAmt != oldClaimPayment.CheckAmt) {
				if(command!=""){ command+=",";}
				command+="CheckAmt = '"+POut.Double(claimPayment.CheckAmt)+"'";
			}
			if(claimPayment.CheckNum != oldClaimPayment.CheckNum) {
				if(command!=""){ command+=",";}
				command+="CheckNum = '"+POut.String(claimPayment.CheckNum)+"'";
			}
			if(claimPayment.BankBranch != oldClaimPayment.BankBranch) {
				if(command!=""){ command+=",";}
				command+="BankBranch = '"+POut.String(claimPayment.BankBranch)+"'";
			}
			if(claimPayment.Note != oldClaimPayment.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(claimPayment.Note)+"'";
			}
			if(claimPayment.ClinicNum != oldClaimPayment.ClinicNum) {
				if(command!=""){ command+=",";}
				command+="ClinicNum = "+POut.Long(claimPayment.ClinicNum)+"";
			}
			if(claimPayment.DepositNum != oldClaimPayment.DepositNum) {
				if(command!=""){ command+=",";}
				command+="DepositNum = "+POut.Long(claimPayment.DepositNum)+"";
			}
			if(claimPayment.CarrierName != oldClaimPayment.CarrierName) {
				if(command!=""){ command+=",";}
				command+="CarrierName = '"+POut.String(claimPayment.CarrierName)+"'";
			}
			if(claimPayment.DateIssued != oldClaimPayment.DateIssued) {
				if(command!=""){ command+=",";}
				command+="DateIssued = "+POut.Date(claimPayment.DateIssued)+"";
			}
			if(claimPayment.IsPartial != oldClaimPayment.IsPartial) {
				if(command!=""){ command+=",";}
				command+="IsPartial = "+POut.Bool(claimPayment.IsPartial)+"";
			}
			if(claimPayment.PayType != oldClaimPayment.PayType) {
				if(command!=""){ command+=",";}
				command+="PayType = "+POut.Long(claimPayment.PayType)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE claimpayment SET "+command
				+" WHERE ClaimPaymentNum = "+POut.Long(claimPayment.ClaimPaymentNum);
			Db.NonQ(command);
			return true;
		}
예제 #33
0
        public List <Guid> MapClaim(IOrganizationService svc, MappedRow mappedRow, BordereauTemplate template, BordereauProcess bxProcess)
        {
            ThrowIf.Argument.IsNull(svc, "svc");
            ThrowIf.Argument.IsNull(mappedRow, "mappedRow");
            ThrowIf.Argument.IsNull(template, "template");
            ThrowIf.Argument.IsNull(bxProcess, "bxProcess");

            Guid        createdClaimId = Guid.Empty;
            List <Guid> createdClaim   = new List <Guid>();

            try
            {
                //Get the template columns
                var templateColumns = template.TemplateColumns.ToArray();
                var country         = bxProcess.CountryRef;

                //Get the distinct claim orders that will differentiate between multiple claims
                var retreievedClaimOrders = templateColumns
                                            .Where(c => c.ClaimOrder != null)
                                            .Select(c => c.ClaimOrder)
                                            .Distinct();

                var order = mappedRow.Attributes
                            .ForEntity("new_claim")
                            .Where(c => c.TemplateColumn.ClaimOrder != null)
                            .Select(c => c.TemplateColumn.ClaimOrder)
                            .Distinct();

                //Get all the common fields between all claims
                var claimAttributeValue = mappedRow.Attributes
                                          .ForEntity("new_claim")
                                          .ForClaimOrder(null);

                mapAttribute.claimStatus = mappedRow.Attributes
                                           .ForAttribute("statuscode")
                                           .FirstOrDefault().AsOptionSet();

                CheckClaimAttributes(svc, mappedRow);

                foreach (var claimOrder in retreievedClaimOrders)
                {
                    #region Claim
                    //Get the fileds based on the Claim Order
                    var claimValueBasedOnClaimOrder = mappedRow.Attributes
                                                      .ForEntity("new_claim")
                                                      .ForClaimOrder(claimOrder);

                    var reserveFieldRowValue = claimValueBasedOnClaimOrder
                                               .ForAttribute("new_reserve")
                                               .FirstOrDefault().AsDecimal();

                    var peril = claimValueBasedOnClaimOrder
                                .ForAttribute("new_peril1")
                                .FirstOrDefault().AsString();

                    var subPeril = claimValueBasedOnClaimOrder
                                   .ForAttribute("new_subperil")
                                   .FirstOrDefault().AsString();

                    mapAttribute.excess = claimValueBasedOnClaimOrder
                                          .ForAttribute("new_policyexcess")
                                          .FirstOrDefault().AsDecimal();

                    //If reserve field is empty we dont create a claim
                    //if (peril != null && peril != "" && subPeril != null && subPeril != "")
                    if (subPeril != null && subPeril != "")
                    {
                        if (reserveFieldRowValue != null && reserveFieldRowValue > 0)
                        {
                            //GetClaimValues(svc, mappedRow, claimOrder);
                            mapAttribute.Reserve = reserveFieldRowValue;

                            if (claimValueBasedOnClaimOrder.Where(c => c.AttributeName == "new_claimedamount").Select(c => c.Value).FirstOrDefault() != null)
                            {
                                mapAttribute.ClaimedAmount = claimValueBasedOnClaimOrder
                                                             .ForAttribute("new_claimedamount")
                                                             .FirstOrDefault()
                                                             .AsDecimal();
                            }
                            //Get the broker claim reference
                            var claimRefValue = mappedRow.Attributes
                                                .ForEntity("new_claim")
                                                .ForAttribute("new_claimreference")
                                                .FirstOrDefault().AsString();

                            mapAttribute.claimFolderReferenceValue = mappedRow.Attributes
                                                                     .ForEntity("new_claim")
                                                                     .ForAttribute("new_claimreference")
                                                                     .FirstOrDefault().AsString();

                            mapAttribute.brokerId = bxProcess.BrokerRef.Id;

                            mapAttribute.bxprocessId = bxProcess.Id;

                            mapAttribute.lossTypeDescription = claimValueBasedOnClaimOrder
                                                               .ForAttribute("new_losstypedescription")
                                                               .FirstOrDefault().AsString();

                            mapAttribute.BrokerClaimReference = claimAttributeValue
                                                                .ForAttribute("new_claimreference")
                                                                .FirstOrDefault().AsString();

                            var riskSubClass = mappedRow.Attributes.ForEntity("new_claim").ForClaimOrder(claimOrder).ForAttribute("new_insuredrisk").FirstOrDefault();

                            //Map the claim fields to be imported
                            Claim claim = new Claim(svc);

                            if (riskSubClass.Value != "Buildings and Contents")
                            {
                                GetClaimValues(svc, mappedRow, claimOrder, riskSubClass.Value);
                                claim.CreateOrUpdateClaim(mapAttribute);
                            }
                            else
                            {
                                GetClaimValues(svc, mappedRow, claimOrder, "Buildings");
                                claim.CreateOrUpdateClaim(mapAttribute);
                                GetClaimValues(svc, mappedRow, claimOrder, "Contents");
                                claim.CreateOrUpdateClaim(mapAttribute);
                                //continue;
                            }

                            //createdClaimId = claim.CreateOrUpdateClaim();

                            //if (createdClaimId != Guid.Empty)
                            //    createdClaim.Add(createdClaimId);
                            #endregion Claim

                            #region Payment
                            //Get the payment fields and map
                            ClaimPayment payment = new ClaimPayment(svc, mappedRow, country, claimOrder);

                            payment.CreateOrUpdatePayment(createdClaimId, mapAttribute.policy.FirstOrDefault());

                            if (mapAttribute.claimStatus.Value == 100000001)
                            {
                                payment.UpdateClaimPaymentStatus(createdClaimId);
                            }

                            #endregion Payment

                            #region Recovery
                            ClaimRecovery recovery = new ClaimRecovery(svc, mappedRow, country, claimOrder);
                            recovery.CreateOrUpdateRecovery(createdClaimId, mapAttribute.policy.FirstOrDefault());

                            if (mapAttribute.claimStatus.Value == 100000001)
                            {
                                recovery.UpdateClaimRecoveryStatus(createdClaimId);
                                //payment.UpdateClaimPaymentStatus(createdClaimId);
                            }

                            #endregion
                        }
                    }
                }

                #region RoleInClaim
                //var retreievedRoleTypeOrder = templateColumns
                //    .Where(c => c.ClaimOrder == claimOrder && c.ClaimRoleTypeOrder != null)
                //    .Select(c => c.ClaimRoleTypeOrder).Distinct();

                var retreievedRoleTypeOrder = templateColumns
                                              .Where(c => c.ClaimRoleTypeOrder != null)
                                              .Select(c => c.ClaimRoleTypeOrder).Distinct();

                Guid createdVehicleId = Guid.Empty;

                Entity roleInClaim = null;

                foreach (var roleTypeOrder in retreievedRoleTypeOrder)
                {
                    //var allRoleAttributes = mappedRow.Attributes.ForClaimOrder(claimOrder).ForRoleNumber(roleTypeOrder);
                    var allRoleAttributes = mappedRow.Attributes.ForRoleNumber(roleTypeOrder);
                    var contactFirstname  = allRoleAttributes.ForAttribute("firstname").FirstOrDefault().AsString();
                    var contactLastName   = allRoleAttributes.ForAttribute("lastname").FirstOrDefault().AsString();
                    if (contactFirstname != null && contactLastName != null)
                    {
                        roleInClaim = CreateRoleInClaim(svc, allRoleAttributes, createdClaimId, country);
                    }

                    var riskClass = bxProcess.RiskClassRef.Name;
                    if (riskClass.ToLower() == "vehicle")
                    {
                        var check = allRoleAttributes.Where(c => c.AttributeName == "new_registrationnumber").FirstOrDefault();

                        if (check != null)
                        {
                            var vehicleRegistrationNo = allRoleAttributes.ForAttribute("new_registrationnumber").FirstOrDefault().AsString();
                            if (vehicleRegistrationNo != null)
                            {
                                createdVehicleId = CreateVehicle(svc, allRoleAttributes, createdClaimId);
                            }

                            if (createdVehicleId != Guid.Empty)
                            {
                                roleInClaim["new_vehicleid"] = new EntityReference("new_vehicle", createdVehicleId);
                                svc.Update(roleInClaim);
                            }
                        }
                    }
                }

                #endregion
            }
            catch (InvalidPluginExecutionException e)
            {
                throw new InvalidPluginExecutionException(e.Message, e.InnerException);
            }
            //catch (Exception ex)
            //{
            //    throw new Exception(ex.Message);
            //}
            return(createdClaim);
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            try
            {
                LabelError.Text = "";
                string claimNumberList = "";
                bool   hasError        = false;
                PanelErrorSpace.Visible = false;
                PanelSaveSpace.Visible  = false;
                Guid batchId = Guid.NewGuid();

                foreach (GridViewRow gridViewRow in GridViewResult.Rows)
                {
                    HiddenField hiddenFieldStoreId    = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldStoreId");
                    Label       labelStoreCustomEmail = (Label)gridViewRow.Cells[4].FindControl("LabelStoreCustomEmail");  //3
                    Label       labelClaimNumber      = (Label)gridViewRow.Cells[5].FindControl("LabelClaimNumber");       //4
                    Label       labelValueCurrent     = (Label)gridViewRow.Cells[6].FindControl("LabelClaimValueCurrent"); //5
                    //Label labelPaidEmail = (Label)gridViewRow.Cells[10].FindControl("LabelStoreCustomEmail");
                    CheckBox    checkBoxPayment       = (CheckBox)gridViewRow.Cells[2].FindControl("CheckBoxPayment");     //11
                    HiddenField hiddenFieldClaimMonth = (HiddenField)gridViewRow.Cells[12].FindControl("HiddenFieldClaimMonth");

                    if (checkBoxPayment.Checked)
                    {
                        ClaimPayment claimPayment = new ClaimPayment();
                        claimPayment.ClaimPaymentId    = 0;
                        claimPayment.ClaimNumber       = labelClaimNumber.Text;
                        claimPayment.StoreId           = Convert.ToInt32(hiddenFieldStoreId.Value);
                        claimPayment.ClaimValueCurrent = Convert.ToDecimal(labelValueCurrent.Text);
                        claimPayment.PaidEmail         = labelStoreCustomEmail.Text;
                        claimPayment.ClaimMonth        = hiddenFieldClaimMonth.Value.ToString();//String.Format("{0}/01",hiddenFieldClaimMonth.Value.ToString());
                        claimPayment.BatchId           = batchId;
                        claimPayment.CompanyId         = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId;
                        claimPayment.ModifiedUser      = this.Master.LoggedOnAccount;

                        claimPayment.Save();
                    }
                }

                foreach (GridViewRow gridViewRow in GridViewResult.Rows)
                {
                    Label    labelClaimNumber = (Label)gridViewRow.Cells[5].FindControl("LabelClaimNumber");
                    CheckBox checkBoxPayment  = (CheckBox)gridViewRow.Cells[2].FindControl("CheckBoxPayment");

                    if (checkBoxPayment.Checked)
                    {
                        claimNumberList += labelClaimNumber.Text + ",";
                    }
                }


                if (Convert.ToInt32(DropDownListLocation.SelectedValue) == 0)
                {
                    SearchByTextBox();
                }
                else
                {
                    BindGridViewResult();
                }

                SendNotification(batchId);

                LabelError.Text         = "Selected Stores have been emailed current Claim Values.";
                PanelError.Visible      = true;
                PanelErrorSpace.Visible = false;
                PanelSaveSpace.Visible  = true;
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
        }
예제 #35
0
 ///<summary></summary>
 public FormClaimPayEdit(ClaimPayment claimPaymentCur)
 {
     InitializeComponent();            // Required for Windows Form Designer support
     ClaimPaymentCur = claimPaymentCur;
     Lan.F(this);
 }