Beispiel #1
0
        public JsonResult changeDeleteDCRFromSession(string id)
        {
            temp_TRN_DCR_DET tmpdet = (temp_TRN_DCR_DET)Session["DCREntry" + id];

            if (tmpdet != null)
            {
                tmpdet.setdeleted();
                Session["DCREntry" + id + "del"] = tmpdet;
                TRN_DCR_DET trn_dcr_det = db.TRN_DCR_DET.Where(t => t.DCR_DET_NO == tmpdet.editID).Single();

                return(Json(new { dt = id, html = getDetailFieldsINT(trn_dcr_det.TRN_DCR.DCR_TYPE_NO, tmpdet.editID) }));
            }
            return(Json((new { dt = "Not Found" })));
        }
Beispiel #2
0
 public JsonResult SaveDCROnSession(decimal?id, decimal?qty, string type, decimal?teacher_no,
                                    decimal?is_behalf, string teacher_mobile, string BEHALF_MOBILE, string rcvType, decimal detID)
 {
     Session["DCREntry" + type + "-" + id] = new temp_TRN_DCR_DET(id, type, qty, teacher_no, is_behalf, teacher_mobile, BEHALF_MOBILE, rcvType, detID);
     return(Json(new { dt = type + id }));
 }
Beispiel #3
0
 public JsonResult SaveDCROthersOnSession(string type, decimal?teacher_no, string teacher_mobile, string rcvType, decimal detID)
 {
     Session["DCREntry" + type + "-" + teacher_mobile] = new temp_TRN_DCR_DET(null, type, null, teacher_no, null, teacher_mobile, null, rcvType, detID);
     return(Json(new { dt = type + "-" + teacher_mobile }));
 }
Beispiel #4
0
        public ActionResult Create(TRN_DCR trn_dcr)
        {
            if (ModelState.IsValid)
            {
                trn_dcr.TIME_FROM = DateTime.ParseExact(trn_dcr.TRN_DCR_DATE.Year + "-" + trn_dcr.TRN_DCR_DATE.Month + "-" + trn_dcr.TRN_DCR_DATE.Day + " " + trn_dcr.FROM_TIME + ":00,000",
                                                        "yyyy-M-dd H:m:ss,fff", System.Globalization.CultureInfo.InvariantCulture);

                trn_dcr.TIME_TO = DateTime.ParseExact(trn_dcr.TRN_DCR_DATE.Year + "-" + trn_dcr.TRN_DCR_DATE.Month + "-" + trn_dcr.TRN_DCR_DATE.Day + " " + trn_dcr.TO_TIME + ":00,000",
                                                      "yyyy-M-dd H:m:ss,fff", System.Globalization.CultureInfo.InvariantCulture);
                TimeSpan ts = DateTime.Parse(trn_dcr.TIME_TO.ToString()).Subtract(DateTime.Parse(trn_dcr.TIME_FROM.ToString()));
                if (trn_dcr.edit_ID == 0)
                {
                    decimal trn_dcr_no = db.TRN_DCR_INSERT(decimal.Parse(Session["sess_USER_NO"].ToString()),
                                                           decimal.Parse(Session["sess_LOGON_NO"].ToString()),
                                                           trn_dcr.INSERT_OFFLINE_TIME,
                                                           null, null, trn_dcr.DCR_TYPE_NO, trn_dcr.user_ID,
                                                           null, trn_dcr.IS_REF_ZM, trn_dcr.user_ID, trn_dcr.REF_ZM_MOBILE, null,
                                                           trn_dcr.WORK_AREA_FROM_LAT, trn_dcr.WORK_AREA_FROM_LON, trn_dcr.WORK_AREA_FROM_NAME,
                                                           trn_dcr.WORK_AREA_TO_LAT, trn_dcr.WORK_AREA_TO_LON, trn_dcr.WORK_AREA_TO_NAME,
                                                           trn_dcr.TIME_FROM, trn_dcr.TIME_TO, Convert.ToDecimal(ts.Hours), trn_dcr.DIVISION_NO,
                                                           trn_dcr.ZONE_NO, trn_dcr.ZILLA_NO, trn_dcr.THANA_NO, trn_dcr.INSTITUTE_NO,
                                                           trn_dcr.TRANS_TYPE_NO, trn_dcr.FARE_AMT, trn_dcr.TRN_DCR_DATE, 1,
                                                           null, trn_dcr.COMMENTS).FirstOrDefault().Value;
                    trn_dcr.DCR_NO = trn_dcr_no;
                }
                else
                {
                    db.TRN_DCR_UPDATE(trn_dcr.edit_ID,
                                      decimal.Parse(Session["sess_USER_NO"].ToString()),
                                      decimal.Parse(Session["sess_LOGON_NO"].ToString()), trn_dcr.UPDATE_OFFLINE_TIME,
                                      trn_dcr.UPDATE_OFFLINE_SYNC, 1, trn_dcr.DCR_TYPE_NO, trn_dcr.user_ID,
                                      null, trn_dcr.IS_REF_ZM, null, trn_dcr.REF_ZM_MOBILE,
                                      null, trn_dcr.WORK_AREA_FROM_LAT, trn_dcr.WORK_AREA_FROM_LON, trn_dcr.WORK_AREA_FROM_NAME,
                                      trn_dcr.WORK_AREA_TO_LAT, trn_dcr.WORK_AREA_TO_LON, trn_dcr.WORK_AREA_TO_NAME,
                                      trn_dcr.TIME_FROM, trn_dcr.TIME_TO, Convert.ToDecimal(ts.Hours), trn_dcr.DIVISION_NO,
                                      trn_dcr.ZONE_NO, trn_dcr.ZILLA_NO, trn_dcr.THANA_NO, trn_dcr.INSTITUTE_NO,
                                      trn_dcr.TRANS_TYPE_NO, trn_dcr.FARE_AMT, trn_dcr.APPROVE_TRANS_TYPE_NO,
                                      trn_dcr.APPROVE_FARE_AMT, trn_dcr.TRN_DCR_DATE, 1, null, trn_dcr.COMMENTS);
                }
                List <string> lstTmp = new List <string>();
                foreach (string curSession in Session)
                {
                    if (curSession.Contains("DCREntry"))
                    {
                        lstTmp.Add(curSession);
                        temp_TRN_DCR_DET temp_sess_det = (temp_TRN_DCR_DET)Session[curSession];
                        TRN_DCR_DET      det           = (temp_sess_det.editID != 0) ? db.TRN_DCR_DET.Where(s => s.DCR_DET_NO == temp_sess_det.editID).FirstOrDefault()
                            :db.TRN_DCR_DET.Where(s => s.DCR_NO == ((trn_dcr.DCR_NO == 0) ? trn_dcr.edit_ID : trn_dcr.DCR_NO) &&
                                                  (s.CLIENT_MOBILE == temp_sess_det.client_mobile || s.TEACHER_MOBILE == temp_sess_det.teacher_mobile)).FirstOrDefault();
                        if (!temp_sess_det.set_deleted)
                        {
                            if (det == null)
                            {
                                db.TRN_DCR_DET_INSERT(decimal.Parse(Session["sess_USER_NO"].ToString()),
                                                      decimal.Parse(Session["sess_LOGON_NO"].ToString()),
                                                      DateTime.Now, trn_dcr.INSERT_OFFLINE_SYNC,
                                                      1, ((trn_dcr.DCR_NO == 0) ? trn_dcr.edit_ID : trn_dcr.DCR_NO), (temp_sess_det.RcvType.ToLower() == "teacher") ? 1 : 0, temp_sess_det.teacher_no,
                                                      temp_sess_det.teacher_mobile, temp_sess_det.is_behalf, temp_sess_det.BEHALF_MOBILE,
                                                      (temp_sess_det.type == "specimen") ? temp_sess_det.type_id : null, (temp_sess_det.type == "specimen") ? temp_sess_det.qty : null,
                                                      ((temp_sess_det.RcvType.ToLower() == "teacher") ? 0 : 1), temp_sess_det.client_no, temp_sess_det.client_mobile,
                                                      (temp_sess_det.type == "specimen") ? temp_sess_det.type_id : null, (temp_sess_det.type == "specimen") ? temp_sess_det.qty : null,
                                                      null, null);
                            }
                            else
                            {
                                db.TRN_DCR_DET_UPDATE(det.DCR_DET_NO, decimal.Parse(Session["sess_USER_NO"].ToString()),
                                                      decimal.Parse(Session["sess_LOGON_NO"].ToString()), DateTime.Now,
                                                      det.UPDATE_OFFLINE_SYNC, det.UPDATE_IS_OFFLINE, det.DCR_NO, ((temp_sess_det.RcvType == "client") ? 0 : 1),
                                                      temp_sess_det.teacher_no, temp_sess_det.teacher_mobile, temp_sess_det.is_behalf,
                                                      temp_sess_det.BEHALF_MOBILE, (temp_sess_det.type == "specimen") ? temp_sess_det.type_id : null,
                                                      (temp_sess_det.type == "specimen") ? temp_sess_det.qty : null,
                                                      ((temp_sess_det.RcvType == "client") ? 1 : 0), det.APPROVE_CLIENT_NO, det.APPROVE_CLIENT_MOBILE,
                                                      (temp_sess_det.type == "specimen") ? temp_sess_det.type_id : null, (temp_sess_det.type == "specimen") ? temp_sess_det.qty : null, null, null);
                            }
                        }
                        else
                        {
                            if (det != null)
                            {
                                db.TRN_DCR_DET_DELETE(det.DCR_DET_NO, decimal.Parse(Session["sess_USER_NO"].ToString()),
                                                      decimal.Parse(Session["sess_LOGON_NO"].ToString()));
                            }
                        }
                    }
                }
                foreach (string del in lstTmp)
                {
                    Session.Remove(del);
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.INSTITUTE_NO  = new SelectList(db.SET_INSTITUTE, "INSTITUTE_NO", "INSTITUTE_NAME");
            ViewBag.DCR_TYPE_NO   = new SelectList(db.GEN_DCR_TYPE, "DCR_TYPE_NO", "DCR_TYPE");
            ViewBag.TRANS_TYPE_NO = new SelectList(db.SET_TRANSPORT_TYPE, "TRANS_TYPE_NO", "TRANS_TYPE_NAME");
            return(View(trn_dcr));
        }