public BizResult update(string user) { BizResult res = new BizResult(); if (det1 == null) { throw new Exception("data is null"); } if (updating_verify(res, user, det1)) { det1.ScheduleDate = SafeValue_mb.DateTime_ClearTime(det1.ScheduleDate); det1.ScheduleTime = SafeValue_mb.convertTimeFormat(det1.ScheduleTime); det1.ServiceType = (SafeValue.SafeString(det1.ServiceType).Equals("") ? default_ServiceType : det1.ServiceType); Manager.ORManager.StartTracking(det1, Wilson.ORMapper.InitialState.Updated); Manager.ORManager.PersistChanges(det1); res.status = true; //========== log container no changed C2.CtmJobEventLog elog = new C2.CtmJobEventLog(); elog.Platform_isBackend(); elog.Controller = user; if (oldv_containerNo != null && det1.ContainerNo != null && !oldv_containerNo.Equals(det1.ContainerNo)) { elog.setActionLevel(det1.Id, CtmJobEventLogRemark.Level.Container, -1, "ContainerNo[" + oldv_containerNo + "]->[" + det1.ContainerNo + "]"); elog.log(); } updated_Status_changed(user); updated_to_trip(); updated_to_house(user); resetOldValues(); elog.setActionLevel(det1.Id, CtmJobEventLogRemark.Level.Container, 3); elog.log(); } return(res); }
public BizResult insert(string user, CtmJobDet1 par) { setData(null); if (par == null) { throw new Exception("data is null"); } BizResult res = new BizResult(); if (inserting_verify(res, user, par)) { par.ScheduleDate = SafeValue_mb.DateTime_ClearTime(par.ScheduleDate); par.ScheduleTime = SafeValue_mb.convertTimeFormat(par.ScheduleTime); par.ScheduleStartDate = SafeValue_mb.DateTime_ClearTime(par.ScheduleStartDate); par.ServiceType = (SafeValue.SafeString(par.ServiceType).Equals("") ? default_ServiceType : par.ServiceType); Manager.ORManager.StartTracking(par, Wilson.ORMapper.InitialState.Inserted); Manager.ORManager.PersistChanges(par); res.status = true; det1 = par; updated_Status_changed(user); resetOldValues(); oldv_ServiceType = "";//==== update trips by service type. inserted_auto_CreateTrip(user); updated_to_trip(); resetOldValues(); C2.CtmJobEventLog elog = new C2.CtmJobEventLog(); elog.Platform_isBackend(); elog.Controller = user; elog.setActionLevel(det1.Id, CtmJobEventLogRemark.Level.Container, 1); elog.log(); } return(res); }
public void ImportJob(string batch, string file, out string error_text) { //throw new Exception("importjob"); Aspose.Cells.License license = new Aspose.Cells.License(); license.SetLicense(MapPath("~/Aspose.lic")); //Workbook wb = new Workbook(); byte[] byData = new byte[100]; char[] charData = new char[1000]; List <string> list = new List <string>(); if (file.ToLower().EndsWith(".txt")) { using (System.IO.StreamReader sr = new System.IO.StreamReader(file, true)) { string str; while ((str = sr.ReadLine()) != null) { list.Add(str); } } } int empty_i = 0; string re_text = ""; //Worksheet ws = wb.Worksheets[0]; int existDo = 0; int successJob = 0; int successItem = 0; int errorDo = 0; string notInside = ""; int insideDo = 0; string sql = ""; //throw new Exception("here"); //=================================== version 1 bool beginImport = false; int _row = 0; DateTime payDate = DateTime.Today; string value = ""; string cur = "SGD"; int docId = 0; int index = 0; for (int i = 0; i < list.Count; i++) { _row++; if (empty_i >= 10) { break; } DateTime date = DateTime.Today; string line = list[i]; string[] ar = line.Split('~'); if (i == 0) { ar = line.Split(' '); payDate = SafeValue.SafeDate(ar[7], date); docId = InsertPay(payDate, cur); } if (i == list.Count - 1) { ar = line.Split('~'); decimal locAmt = SafeValue.SafeDecimal(ar[4]); sql = string.Format(@"update XAApPayment set DocAmt={1}, LocAmt={1} where SequenceId={0}", docId, locAmt); ConnectSql_mb.ExecuteNonQuery(sql); continue; } if (i == 4) { ar = line.Split(':'); cur = ar[1]; } if (ar[0] == "Invoice No.") { beginImport = true; empty_i++; continue; } //throw new Exception(ws.Cells["A" + i].Type.ToString()); try { value = list[i]; } catch { empty_i++; continue; } if (line.Length <= 0) { empty_i++; continue; } empty_i = 0; if (beginImport) { index++; string invNo = SafeValue.SafeString(ar[0]); DateTime invDate = SafeValue.SafeDate(ar[1], date); //string docType = SafeValue.SafeString(ar[2]); decimal amt = SafeValue.SafeDecimal(ar[4]); //=====================检测是否存在Bill Number string billDate = invDate.ToString("yyyy-MM-dd"); string sql_check = string.Format(@"select count(*) from XAApPaymentDet where Remark1='{0}'", invNo); int check_n = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_check), 0); if (check_n > 0) { existDo++; continue; } else { try { sql_check = string.Format(@"select SequenceId,DocNo,DocType,CurrencyId,DocDate from XAApPayable where SupplierBillNo='{0}' and SupplierBillDate='{1}'", invNo, billDate); DataTable dt_check = ConnectSql.GetTab(sql_check); if (dt_check.Rows.Count > 0) { string docNo = SafeValue.SafeString(dt_check.Rows[0]["DocNo"]); string docType = SafeValue.SafeString(dt_check.Rows[0]["DocType"]); DateTime docDate = SafeValue.SafeDate(dt_check.Rows[0]["DocDate"], DateTime.Today); InsertPay_Det(docId, docNo, docType, index, invNo, "", "", 1, amt, cur, 1, 0, "", "", "", "", invDate); successJob++; } else { insideDo++; if (insideDo == 1) { notInside += invNo; } else { notInside += invNo + ","; } } } catch (Exception ex) { //errorDo++; throw new Exception(_row.ToString() + "##" + ex.Message); } } } else { } } sql = string.Format(@"select DocNo,DocDate,LocAmt from XAApPayment where SequenceId={0}", docId); DataTable dt_pay = ConnectSql_mb.GetDataTable(sql); string billNo = ""; decimal totalAmt = 0; DateTime docDate1 = DateTime.Today; if (dt_pay.Rows.Count > 0) { billNo = SafeValue_mb.SafeString(dt_pay.Rows[0]["DocNo"]); totalAmt = SafeValue.SafeDecimal(dt_pay.Rows[0]["LocAmt"]); docDate1 = SafeValue.SafeDate(dt_pay.Rows[0]["DocDate"], DateTime.Today); } re_text = string.Format(@"uploaded {0} lines", successJob); re_text += successItem > 0 ? string.Format(@" {0} items.", successItem) : "."; re_text += existDo > 0 ? string.Format(@" {0} existed", existDo) : ""; re_text += errorDo > 0 ? string.Format(@" {0} error", errorDo) : ""; re_text += insideDo > 0 ? string.Format(@" ,{0} not inside the payable", "Invoice:【" + notInside + "】") : ""; error_text = re_text; string user = HttpContext.Current.User.Identity.Name; string sql1 = string.Format(@"insert into CTM_JobEventLog (CreateDatetime,Controller,JobType,Remark,Note1,Note2,Value1) values (getdate(),@Controller,@JobType,@Remark,@Note1,@Note2,@Value1)"); List <ConnectSql_mb.cmdParameters> list1 = new List <ConnectSql_mb.cmdParameters>(); list1.Add(new ConnectSql_mb.cmdParameters("@Controller", user, SqlDbType.NVarChar, 100)); list1.Add(new ConnectSql_mb.cmdParameters("@JobType", "GIRO", SqlDbType.NVarChar, 100)); list1.Add(new ConnectSql_mb.cmdParameters("@Remark", re_text, SqlDbType.NVarChar, 300)); list1.Add(new ConnectSql_mb.cmdParameters("@Note1", billNo, SqlDbType.NVarChar, 300)); list1.Add(new ConnectSql_mb.cmdParameters("@Note2", docDate1.ToString("yyyy-MM-dd"), SqlDbType.NVarChar, 300)); list1.Add(new ConnectSql_mb.cmdParameters("@Value1", totalAmt, SqlDbType.NVarChar, 300)); ConnectSql_mb.sqlResult re1 = ConnectSql_mb.ExecuteNonQuery(sql1, list1); }