Example #1
0
        private Decimal getProgramAmount(Guid? stuguid, Guid? progGuid)
        {
            Decimal result = 0;

            BestField p1 = new BestField() { fieldName = "studentguid", fieldType = "System.Guid", fieldSize = 40, paramOledbType = System.Data.OleDb.OleDbType.Guid };
            p1.fieldValue = stuguid.ToString();
            BestField p2 = new BestField() { fieldName = "guidfield", fieldType = "System.Guid", fieldSize = 40, paramOledbType = System.Data.OleDb.OleDbType.Guid };
            p2.fieldValue = progGuid.ToString();
            List<BestField> bparams = new List<BestField>();
            bparams.Add(p1);
            bparams.Add(p2);

            BestStudentPrograms bstdProgs = new BestStudentPrograms();
            bstdProgs.LoadRows("studentguid=? and guidfield=?", bparams);
            if (bstdProgs.HasRows)
            {
                bstdProgs.currentRowId = 0;
                result = bstdProgs.Amount;
            }

            return result;
        }
Example #2
0
        private void SavePrograms(Guid studentGuid)
        {
            string programsData = Request.Form["programsData"];
            if (!string.IsNullOrEmpty(programsData))
            {
                string[] aryProgs = programsData.Split('\n');
                for (int i = 0; i < aryProgs.Length; i++)
                {
                    string[] aryFields = aryProgs[i].Split('\t');
                    Decimal ddamt;
                    if (aryFields[0].Length > 16)
                    {
                        /* Edit or Delete */
                        BestStudentPrograms bstdProg = new BestStudentPrograms();
                        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 = aryFields[0];
                        bparams.Add(guid);

                        if (!string.IsNullOrEmpty(guid.fieldValue))
                        {
                            bstdProg.LoadRows("guidfield=?", bparams);
                        }
                        bstdProg.programguid = (Guid)Utils.getNullableGuid(aryFields[1]);
                        Decimal.TryParse(aryFields[2], out ddamt);
                        bstdProg.Amount = ddamt;
                        bstdProg.CurrentRow.IsDelete = aryFields[3].Equals("true\r");
                        bstdProg.CurrentRow.Save();
                    }
                    else if(aryFields[0].Length != 0)
                    {
                        /* Add */
                        Guid? programguid = Utils.getNullableGuid(aryFields[1]);
                        if (programguid != null)
                        {
                            BestStudentPrograms bstdProg = new BestStudentPrograms();
                            bstdProg.studentGuid = studentGuid;
                            bstdProg.programguid = new Guid(aryFields[1]);
                            Decimal.TryParse(aryFields[2], out ddamt);
                            bstdProg.Amount = ddamt;
                            bstdProg.StudentId = this.StudentId.Value;
                            bstdProg.CenterId = this.CenterId.Value;
                            bstdProg.CurrentRow.Save();
                        }
                    }
                }
            }
        }
Example #3
0
        private string StudentPrograms()
        {
            StringBuilder sbprog = new StringBuilder();
            BestStudentPrograms bstdProg = new BestStudentPrograms();
            bstdProg.LoadRows("CenterId=? and programguid in (select guidfield from bestprograms where amountType not in ('OneTime', 'Year'))", Utils.User.CIdParam, "studentguid");
            sbprog.AppendLine("StudentProgs = [");
            string firstguid = "";
            int sequence = 0;
            for (int i = 0; i < bstdProg.TableRows.Count; i++)
            {
                bstdProg.currentRowId = i;
                if (!firstguid.Equals(bstdProg.studentGuid.ToString()))
                {
                    sequence = 0;
                    firstguid = bstdProg.studentGuid.ToString();
                }
                sequence++;
                sbprog.Append("{guidfield:\"" + bstdProg.guidfield.ToString() + "\",studentguid:\"" + bstdProg.studentGuid.ToString() + "\", progGuid:\"" + bstdProg.programguid.ToString() + "\", Amount:" + bstdProg.Amount.ToString("0.00") + ", Index:" + sequence.ToString() + "}");
                if (i < bstdProg.TableRows.Count - 1) sbprog.Append(",");
            }
            sbprog.AppendLine("]");

            sbprog.AppendLine("jsProg=[");
            BestPrograms bps = new BestPrograms();
            bps.LoadRows();
            for (int rnum = 0; rnum < bps.TableRows.Count; rnum++)
            {
                bps.currentRowId = rnum;
                sbprog.Append("{guid:\"" + bps.guidfield.ToString() + "\",amount:\"" + bps.amount + "\",amountType:\"" + bps.amountType + "\",progName:\"" + bps.programName + "\",progType:\"" + bps.programType + "\"}");
                if (rnum < bps.TableRows.Count - 1) sbprog.Append(",");
            }
            sbprog.Append("]");

            return sbprog.ToString();
        }