Beispiel #1
0
        public PaymentDetails()
        {
            this.TableName = "BestPaymentDetails";
            this.SecurityPage = "Payment - Details";

            TableFields.Add(new BestField() { fieldName = "paymentTypeGuid", fieldHeader = "Program Type", displayField = true, fieldSize = 128, IsRequired = true, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid,
                      displayFormatFunc = new Func<BestRow, object>((obj) =>
                      {
                          BestRow pd = (BestRow)obj;
                          List<BestField> bparams = new List<BestField>();
                          BestField guid = new BestField() { fieldName = "paymentTypeGuid", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
                          guid.fieldValue = pd.Fields["paymentTypeGuid"].fieldValue;
                          bparams.Add(guid);
                          PaymentTypes bptype = new PaymentTypes();
                          bptype.LoadRows("guidfield=?", bparams);
                          return bptype.paymentType;
                      })
            });

            TableFields.Add(new BestField() { fieldName = "studentGuid", fieldHeader = "Student", displayField = true, fieldSize = 128, IsRequired = true, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid,
                displayFormatFunc = new Func<BestRow,object>((obj)=>
                    {
                        BestRow pd = (BestRow)obj;
                        List<BestField> bparams = new List<BestField>();
                        BestField guid = new BestField() { fieldName = "studentGuid", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
                        guid.fieldValue = pd.Fields["studentGuid"].fieldValue;
                        bparams.Add(guid);
                        BestStudents bpstd = new BestStudents();
                        bpstd.LoadRows("guidfield=?", bparams);
                        return bpstd.firstName + " " + bpstd.lastName;
                    })
            });

            TableFields.Add(new BestField() { fieldName = "amount", fieldHeader = "Amount", displayField = true, fieldSize = 18, IsRequired = false, fieldType = "System.Decimal", paramOledbType = System.Data.OleDb.OleDbType.Decimal });
            TableFields.Add(new BestField() { fieldName = "paymentDate", fieldHeader = "Payment Date", displayField = true, fieldSize = 10, IsRequired = false, fieldType = "System.DateTime", paramOledbType = System.Data.OleDb.OleDbType.DBTimeStamp,
               displayFormatFunc = new Func<BestRow,object>((obj)=>
                {
                    BestRow br = (BestRow) obj;
                    DateTime dt = Convert.ToDateTime(br.Fields["paymentDate"].fieldValue);
                    return dt.ToString("MM/dd/yyyy");
                })
            });

            TableFields.Add(new BestField() { fieldName = "guidfield", fieldHeader = "guid", displayField = false, fieldSize = 40, IsRequired = false, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid });
            TableFields.Add(new BestField() { fieldName = "lastChange", fieldHeader = "Last Change", displayField = false, fieldSize = 20, IsRequired = false, fieldType = "System.DateTime", paramOledbType = System.Data.OleDb.OleDbType.DBTimeStamp });
            TableFields.Add(new BestField() { fieldName = "lastChangeUser", fieldHeader = "Last Change User", displayField = false, fieldSize = 128, IsRequired = false, fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar });
            TableFields.Add(new BestField() { fieldName = "hours", fieldHeader = "Hours", displayField = true, fieldSize = 18, IsRequired = false, fieldType = "System.Decimal", paramOledbType = System.Data.OleDb.OleDbType.Decimal, Precision = 18, scale = 2 });
            TableFields.Add(new BestField() { fieldName = "CenterId", displayField = true, fieldHeader = "Center Id", fieldType = "System.String", paramOledbType = System.Data.OleDb.OleDbType.VarChar, fieldSize = 50 });
        }
Beispiel #2
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.PaymentMenu("paymentdetails");
            if (!Utils.User.UserRoleByName("Payment - Details").allowView)
            {
                ltrGrid.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            ltrMScript.Text = Utils.MenuSelectScript(ms);

            string saveClicked = Request.Form["SaveClicked"] ?? "";
            if (IsPostBack && saveClicked.Equals("1"))
            {
                PaymentDetails bs = new PaymentDetails();
                string isnew = Request.Form["isnew"];
                bool cansave = true;
                if (string.IsNullOrEmpty(isnew))
                {
                    List<BestField> bparams = new List<BestField>();
                    BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
                    guid.fieldValue = Request.Form["guidfield"];
                    bparams.Add(guid);

                    if (!string.IsNullOrEmpty(guid.fieldValue))
                    {
                        bs.LoadRows("guidfield=?", bparams);
                    }
                    else
                    {
                        string delguid = Request.Form["deleteguid"];
                        if (!string.IsNullOrEmpty(delguid))
                        {
                            bparams[0].fieldValue = delguid;
                            bs.LoadRows("guidfield=?", bparams);
                            bs.CurrentRow.IsDelete = true;
                            bs.CurrentRow.Save();
                        }
                        cansave = false;
                    }
                }

                if (cansave)
                {
                    string stdguid = Request.Form["g_studentGuid"];
                    string payguid = Request.Form["g_paymentTypeGuid"];
                    string amt = Request.Form["g_amount"];
                    string paydate = Request.Form["g_paymentDate"];
                    string hours = Request.Form["g_hours"];
                    if (string.IsNullOrEmpty(payguid))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("Payment Type is Required.");
                        cansave = false;
                    }
                    if (string.IsNullOrEmpty(stdguid))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("Student is Required.");
                        cansave = false;
                    }
                    if (string.IsNullOrEmpty(paydate))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("Payment Date is Required.");
                        cansave = false;
                    }
                    if (cansave)
                    {
                        bs.studentGuid = new Guid(stdguid);
                        bs.paymentTypeGuid = new Guid(payguid);
                        bs.amount = amt;
                        Decimal dhours;
                        Decimal.TryParse(hours, out dhours);
                        bs.hours = dhours;
                        bs.paymentDate = Convert.ToDateTime(paydate);
                        bs.CenterId = Utils.User.CenterId;

                        if (!bs.CurrentRow.Save())
                        {
                            ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
                        }
                    }
                }
            }

            PaymentTypes bpayTypes = new PaymentTypes();
            bpayTypes.LoadRows();
            StringBuilder sbc = new StringBuilder();
            sbc.Append("<option value=\"\"></option>");
            for (int rnum = 0; rnum < bpayTypes.TableRows.Count; rnum++)
            {
                string paytype = bpayTypes.TableRows[rnum].Fields["paymentType"].fieldValue;
                string guid = bpayTypes.TableRows[rnum].Fields["guidfield"].fieldValue;
                sbc.Append("<option value=\"" + HttpUtility.HtmlEncode(guid) + "\">" + HttpUtility.HtmlEncode(paytype) + "</option>");
            }
            ltrPayTypes.Text = sbc.ToString();

            /* Auto Student */
            string autoSample = "{value:\"[paramValue]\", label:[paramLabel]}";
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("autoStudents = [");
            BestStudents bstd = new BestStudents();
            bstd.LoadRows("CenterId=?", Utils.User.CIdParam);
            for (int s = 0; s < bstd.TableRows.Count; s++)
            {
                string result = autoSample;
                result = result.Replace("[paramValue]", bstd.TableRows[s].Fields["guidfield"].fieldValue);
                result = result.Replace("[paramLabel]", Utils.EnquoteJS((bstd.TableRows[s].Fields["firstName"].fieldValue ?? "") + " " +
                    (bstd.TableRows[s].Fields["lastName"].fieldValue ?? "")));
                sb.Append(result);
                if (s < bstd.TableRows.Count - 1) sb.AppendLine(",");
            }
            sb.AppendLine("];");
            ltrScript.Text = @"<script type=""text/javascript"">
            $(document).ready(function(){ " + sb.ToString() + @"
            $('#studentTag1').autocomplete( { source:autoStudents, delay: 0, select : function( event, ui){
            $('#studentGuid').val( ui.item.value );
            $( this ).val( ui.item.label );
            return false;
            } } ); }); </script>";

            BestGrid bsGrid = new BestGrid();
            bsGrid.PageRequest = Page.Request;
            bsGrid.Title = "Payment Details";
            bsGrid.GridTable = new PaymentDetails();
            bsGrid.securityPage = "Payment - Details";
            ltrGrid.Text = bsGrid.ToHTML();
        }
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["CurrentUser"] == null)
            {
                Response.Redirect("Logout.aspx");
            }
            ltrSubMenu.Text = UtilMenu.PaymentMenu("paymenttypes");
            if (!Utils.User.UserRoleByName("Payment - Types").allowView)
            {
                ltrGrid.Text = "You do not have rights to view.";
                return;
            }

            string ms = Request.QueryString["ms"];
            ltrMScript.Text = Utils.MenuSelectScript(ms);

            string saveClicked = Request.Form["SaveClicked"] ?? "";
            if (IsPostBack && saveClicked.Equals("1"))
            {
                PaymentTypes bs = new PaymentTypes();
                string isnew = Request.Form["isnew"];
                bool cansave = true;
                if (string.IsNullOrEmpty(isnew))
                {
                    List<BestField> bparams = new List<BestField>();
                    BestField guid = new BestField() { fieldName = "guidfield", fieldSize = 40, fieldType = "System.Guid", paramOledbType = System.Data.OleDb.OleDbType.Guid, displayField = false };
                    guid.fieldValue = Request.Form["guidfield"];
                    bparams.Add(guid);

                    if (!string.IsNullOrEmpty(guid.fieldValue))
                    {
                        bs.LoadRows("guidfield=?", bparams);
                    }
                    else
                    {
                        string delguid = Request.Form["deleteguid"];
                        if (!string.IsNullOrEmpty(delguid))
                        {
                            bparams[0].fieldValue = delguid;
                            bs.LoadRows("guidfield=?", bparams);
                            bs.CurrentRow.IsDelete = true;
                            bs.CurrentRow.Save();
                        }
                        cansave = false;
                    }
                }

                if (cansave)
                {
                    bs.paymentType = Request.Form["g_paymentType"];
                    if (string.IsNullOrEmpty(bs.paymentType))
                    {
                        ltrValidateMsg.Text = Utils.WarningMessage("Payment Type is Required.");
                        cansave = false;
                    }
                    if (cansave)
                    {
                        if (!bs.CurrentRow.Save())
                        {
                            ltrValidateMsg.Text = Utils.WarningMessage(bs.CurrentRow.lastError);
                        }
                    }
                }
            }

            BestGrid bsGrid = new BestGrid();
            bsGrid.PageRequest = Page.Request;
            bsGrid.Title = "Payment Types";
            bsGrid.securityPage = "Payment - Types";
            bsGrid.GridTable = new PaymentTypes();
            ltrGrid.Text = bsGrid.ToHTML();
        }