public static void CreateAndRaise() { var p = new Pub(); p.OnChange += (sender, e) => { Console.WriteLine("Subscrober 1 called"); }; p.OnChange += (sender, e) => { { throw new Exception(); } }; p.OnChange += (sender, e) => { Console.WriteLine("Subscriber 3 called"); }; try { p.Raise(); } catch (AggregateException ex) { Console.WriteLine("{0} exceptions caught", ex.InnerExceptions.Count); } }
public void Test_Customer_2女1男_收費標準100_Income應為100() { //arrange ICheckInFee stubCheckInFee = MockRepository.GenerateStub<ICheckInFee>(); Pub target = new Pub(stubCheckInFee); stubCheckInFee.Stub(x => x.GetFee(Arg<Customer>.Is.Anything)).Return(100); var customers = new List<Customer> { new Customer{ IsMale=true}, new Customer{ IsMale=false}, new Customer{ IsMale=false}, }; var inComeBeforeCheckIn = target.GetInCome(); Assert.AreEqual(0, inComeBeforeCheckIn); decimal expectedIncome = 100; //act var chargeCustomerCount = target.CheckIn(customers); var actualIncome = target.GetInCome(); //assert Assert.AreEqual(expectedIncome, actualIncome); }
public void Run() { var p = new Pub(); p.OnChange += () => Console.WriteLine("Event raised to method 1"); p.OnChange += () => Console.WriteLine("Event raised to method 2"); p.Raise(); }
public void Run() { var p = new Pub(); p.OnChange += (sender, e) => Console.WriteLine("Event raised: {0}", e.Value); p.Raise(); }
public static void CreateAndRaise() { var p = new Pub(); p.OnChange += (sender, e) => { Console.WriteLine("Event raised: {0}", e.Value); }; p.Raise(); }
static void Main(string[] args) { var p = new Pub(); p.OnChange += OnChange; p.Raise(); Console.Write("Press a key to exit"); Console.ReadKey(); }
static void Main() { Pub irish_pub_thursday = new Pub (Music.Irish, Drinks.All); Pub lunch_break = new Pub (Music.RockPop, Drinks.Coffee | Drinks.Water); Pub dinner = new Pub (Music.Country, Drinks.Tea | Drinks.Juice); Console.WriteLine (irish_pub_thursday); Console.WriteLine (lunch_break); Console.WriteLine (dinner); }
public static void CreateAndRaise() { Pub p = new Pub(); p.OnChange += (sender, e) => Console.WriteLine("Event Raise: {0}", e.Value); p.Raise(); Console.Read(); }
/// <summary> /// 更换IP /// </summary> /// <param name="netType">0表示路由 1表示拨号连接</param> /// <param name="msg">通知输出消息</param> /// <param name="done">完成时执行</param> /// <param name="index">第几次执行</param> /// <returns></returns> public static string ChangeIP(int netType, Action<string> msg = null, Pub.Class.Action done = null, int index = 0) { string name = GetNetName(netType); setting = SendSettingHelper.SelectByID(1); if (setting.IsNull()) { if (!msg.IsNull()) msg("请修改发送设置!"); if (!done.IsNull()) done(); return ""; } else { if (index == setting.MaxRetryCount) { if (!done.IsNull()) done(); return ""; } if (!msg.IsNull()) msg((index + 1).ToString()); //清空多少分钟前的历史IP if (Data.Pool("ConnString").DBType == "SqlServer") { "delete from IpHistory where CreateTime < DateAdd(MINUTE , -{0}, getdate())".FormatWith(setting.DeleteInterval).ToSQL().ToExec(); } else if (Data.Pool("ConnString").DBType == "SQLite" || Data.Pool("ConnString").DBType == "MonoSQLite") { "delete from IpHistory where datetime(CreateTime) < datetime('now','localtime', '-{0} minute')".FormatWith(setting.DeleteInterval).ToSQL().ToExec(); } if (!msg.IsNull()) msg("正在重启" + name + "......"); IController connect; switch (netType) { case 1: connect = new ModelController(); break; case 2: connect = new TianYiController(); break; default: connect = new RouteController(); break; } string error = connect.Reset(); if (!error.IsNullEmpty()) { if (!msg.IsNull()) msg("重启" + name + "失败:" + error); return ChangeIP(netType, msg, done, index + 1); } else { if (!msg.IsNull()) msg("已重启" + name + ",正在检测是否联网......"); bool isTrue = NetHelper.CheckNetwork(msg); if (!isTrue) return ChangeIP(netType, msg, done, index + 1); if (!msg.IsNull()) msg("已联接网络,正在获取IP......"); string ip = IPHelper.GetIpFast(); if (!msg.IsNull()) msg("获取到IP:" + ip); if (IpHistoryHelper.IsExistByID(ip)) { if (!msg.IsNull()) msg("检测到IP:" + ip + "最近已使用!"); return ChangeIP(netType, msg, done, index + 1); } else { IpHistoryHelper.Insert(new IpHistory() { IP = ip, CreateTime = DateTime.Now.ToDateTime().ToDateTime() }); }; return ip; } } }
public static void CreateAndRaise() { var p = new Pub(); p.OnChange += () => { Console.WriteLine("Event raised to method 1"); }; p.OnChange += () => { Console.WriteLine("Event raise to method 2"); }; p.Raise(); }
private void EventUsingActionExample() { Console.WriteLine("Implementing publish subscribe using Action"); Pub p = new Pub(); p.OnChange += () => Console.WriteLine("Event raised from method 1"); p.OnChange += () => Console.WriteLine("Event raised from method 2"); //p.OnChange(); Console.WriteLine("On Change can be called from the subscriber"); p.Raise(); Console.WriteLine("Problem with above implementation is:"); Console.WriteLine("Any subscriber can remove handlers by using = instead of +="); Console.WriteLine("Ideally Pub class should raise the event but using above approach other users can also raise the event"); }
public static void TestIPStart(Action<string> msg, Pub.Class.Action done) { IList<IpSetting> list = IpSettingHelper.SelectListByAll(); if (list.Count == 0) { msg("请设置需要获取IP的网址!"); return; } msg("共有{0}个获取IP的网址!".FormatWith(list.Count)); if (!ex.IsNull()) ex.SetAll(); ex = new ThreadEx(); list.Do((p, i) => { ex.QueueWorkItem(new System.Threading.WaitCallback(o => { IpSetting setting = (IpSetting)o; string ip = string.Empty; try { string data = string.Empty; string name = setting.DataEncode.IfNullOrEmpty("utf-8"); Encoding coding = Encoding.GetEncoding(name); data = GetRemoteHtmlCode(setting.IPUrl, coding); if (data.Trim().IsNullEmpty()) { msg("{0},error - 请检查网址{1}是否正确!".FormatWith(i + 1, setting.IPUrl)); } else { if (setting.IPRegex.IsNullEmpty()) { //允许正则为空 if (data.IsNullEmpty()) { msg("{0},error - 网址{1}无法匹配IP:{2}".FormatWith(i + 1, setting.IPUrl, data)); } else { msg("{0},ok - 网址{1}获取的IP是:{2}".FormatWith(i + 1, setting.IPUrl, data)); } } else { string begin = setting.IPRegex.Substring(0, setting.IPRegex.IndexOf("(")).Replace("\\", ""); string end = setting.IPRegex.Substring(setting.IPRegex.IndexOf(")") + 1).Replace("\\", ""); if (begin.IsNullEmpty() || end.IsNullEmpty()) { msg("{0},error - 请检查网址{1}的正则是否正确:{2}".FormatWith(i + 1, setting.IPUrl, setting.IPRegex)); } else { ip = data.GetMatchingValues(setting.IPRegex, begin, end).Join(","); if (ip.IsNullEmpty()) { msg("{0},error - 网址{1}无法匹配IP:{2}".FormatWith(i + 1, setting.IPUrl, data)); } else { msg("{0},ok - 网址{1}获取的IP是:{2}".FormatWith(i + 1, setting.IPUrl, ip)); } } } } } catch (Exception e) { msg("{0},error - 获取网址{1}数据出错:{2}".FormatWith(i + 1, setting.IPUrl, e.Message)); return; } }), p); }); ex.WaitAllComplete(); done(); }
/// <summary> /// 开始群发邮件 /// </summary> /// <param name="msg">通知消息</param> /// <param name="done">完成执行</param> public void Start(Action<string> msg = null, Pub.Class.Action done = null) { exit = false; uiMsg = msg; uiDone = done; thread = new Thread(() => { smtpList = SmtpListHelper.SelectListByAll(); sendSetting = SendSettingHelper.SelectByID(1); templateList = HtmlTemplateHelper.SelectListByAll().Where(p => p.Status == 0).ToList(); sendStart(); }); thread.IsBackground = true; thread.Start(); }
public void CreateAndRaise() { var p = new Pub(); p.OnChange += (sender, e) => Console.WriteLine("Subscriber 1 called"); p.OnChange += (sender, e) => { throw new Exception(); }; p.OnChange += (sender, e) => Console.WriteLine("Subscriber 3 called"); p.Raise(); }
public static void CreateAndRaise() { Pub p = new Pub(); p.OnChange += (sender, e) => { Console.WriteLine("Subscrober 1 called"); }; p.OnChange += (sender, e) => { { throw new Exception(); } }; p.OnChange += (sender, e) => { Console.WriteLine("Subscriber 3 called"); // Is never called }; p.Raise(); }
public void CheckInTest_Customer_2女1男_應收費人數為1() { //arrange ICheckInFee stubCheckInFee = MockRepository.GenerateStub<ICheckInFee>(); Pub target = new Pub(stubCheckInFee); stubCheckInFee.Stub(x => x.GetFee(Arg<Customer>.Is.Anything)).Return(100); var customers = new List<Customer> { new Customer{ IsMale=true}, new Customer{ IsMale=false}, new Customer{ IsMale=false}, }; decimal expected = 1; //act var actual = target.CheckIn(customers); //assert Assert.AreEqual(expected, actual); }
public Agent(Pub pub, LogHandler logHandler) { Pub = pub; LogHandler = logHandler; }
public void Run() { Pub pub = new Pub(); pub.Raise(); }
private void btnTestConnect_Click(object sender, EventArgs e) { if (!CheckValue()) { return; } TDIConnInfo connInfo = Pub.ValueToDIConnInfo(MacSN, MacSN_GPRS, MacConnType, MacIP, MacPort, MacConnPWD, IsGPRS, MacSeriesTypeId, SeaSeriesPwd, MacSeriesUserName); this.Enabled = false; string dt = ""; bool ret = false; string msg = ""; string Online = ""; DateTime dTime = new DateTime(); try { switch (MacSeriesTypeId) { case 2: if (RegisterInfo.IsValid || RegisterInfo.IsTest) { if (RegisterInfo.EndDate < DateTime.Now) { Pub.MessageBoxShow(RegisterInfo.StateText); return; } } try { string url = "http://" + MacIP + "/action/GetSysTime"; string syncTime = ""; ret = DeviceObject.objFK623.POST_GetResponse(url, MacSeriesUserName, SeaSeriesPwd, ref syncTime); if (ret) { if (syncTime != "") { jsonBody <SeaSeriesSyncTime> answer = JsonConvert.DeserializeObject <jsonBody <SeaSeriesSyncTime> >(syncTime); msg = Pub.GetResText("", "FK_RUN_SUCCESS", "") + "\r\n\r\n" + answer.info.Year + "-" + answer.info.Month + "-" + answer.info.Day + " " + answer.info.Hour + ":" + answer.info.Minute + ":" + answer.info.Second; FK623Attend.SeaBody = Pub.GetResText("", "FK_RUN_SUCCESS", ""); } else { ret = false; msg = Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", "") + "\r\n\r\n" + DeviceObject.objFK623.SeaBodyStr(); } } else { msg = Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", ""); } } catch (Exception E) { msg = E.Message; } break; case 3: if (RegisterInfo.IsValid || RegisterInfo.IsTest) { if (RegisterInfo.EndDate < DateTime.Now) { Pub.MessageBoxShow(RegisterInfo.StateText); return; } } string cmd = "GetDeviceInfo"; DeviceCmd getDeviceCmd = new DeviceCmd(cmd); StringBuilder jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(getDeviceCmd)); int pwd = 0; int.TryParse(MacConnPWD, out pwd); if (DeviceObject.socKetClient.Open(MacIP, Convert.ToInt32(MacPort), pwd)) { if (DeviceObject.socKetClient.SendData(ref jsonStringBuilder)) { int state = DeviceObject.socKetClient.JsonRecive(jsonStringBuilder); if (state == 0) { _ResultInfo <DeviceInfo> deviceInfo = JsonConvert.DeserializeObject <_ResultInfo <DeviceInfo> >(jsonStringBuilder.ToString()); string deviceId = deviceInfo.result_data.deviceId; string deviceName = deviceInfo.result_data.name; ret = true; msg = Pub.GetResText("", "FK_RUN_SUCCESS", "") + "\r\n\r\n" + deviceId + "\r\n\r\n" + deviceName; } else { msg = DeviceObject.socKetClient.GetStarState(state); } } else { ret = false; msg = Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", ""); } } else { ret = false; msg = Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", ""); } DeviceObject.socKetClient.Close(); break; default: DeviceObject.objFK623.Close(); DeviceObject.objFK623.InitConn(connInfo); DeviceObject.objFK623.Open(); ret = DeviceObject.objFK623.GetDeviceTime(ref dTime); DeviceObject.objFK623.Close(); if (ret) { dt = dTime.ToString(); } msg = DeviceObject.objFK623.ErrMsg; if (ret) { msg = msg + "\r\n\r\n" + dt; } break; } if (ret) { Online = Pub.GetResText(formCode, "Online", ""); SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000300, new string[] { "304", Online , "", MacSN_GPRS })); Pub.MessageBoxShow(msg, MessageBoxIcon.Information); } else { Online = Pub.GetResText(formCode, "Offline", ""); SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000300, new string[] { "305", Online, MacSN_GPRS })); Pub.MessageBoxShow(msg); } } catch (Exception E) { Pub.MessageBoxShow(E.Message); } finally { this.Enabled = true; } }
private void btnGetMacSN_Click(object sender, EventArgs e) { if (RegisterInfo.IsValid || RegisterInfo.IsTest) { if (RegisterInfo.EndDate < DateTime.Now) { Pub.MessageBoxShow(RegisterInfo.StateText); return; } } if (!CheckValue()) { return; } TDIConnInfo connInfo = Pub.ValueToDIConnInfo(MacSN, MacSN_GPRS, MacConnType, MacIP, MacPort, MacConnPWD, IsGPRS, MacSeriesTypeId, SeaSeriesPwd, MacSeriesUserName); this.Enabled = false; bool ret = false; string Online = ""; string msg = ""; try { switch (MacSeriesTypeId) { case 2: string syncTime = ""; string url = "http://" + MacIP + "/action/GetSysParam"; ret = DeviceObject.objFK623.POST_GetResponse(url, MacSeriesUserName, SeaSeriesPwd, ref syncTime); if (ret) { if (syncTime != "") { jsonBody <GetSysParam> answer = JsonConvert.DeserializeObject <jsonBody <GetSysParam> >(syncTime); txtMacSN.Text = answer.info.DeviceID.ToString(); Pub.MessageBoxShow(Pub.GetResText("", "MsgReadEndData", "")); Application.DoEvents(); } } else { ret = false; Pub.MessageBoxShow(Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", "")); } break; case 3: string cmd = "GetDeviceInfo"; DeviceCmd getDeviceCmd = new DeviceCmd(cmd); StringBuilder jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(getDeviceCmd)); int pwd = 0; int.TryParse(MacConnPWD, out pwd); if (DeviceObject.socKetClient.Open(MacIP, Convert.ToInt32(MacPort), pwd)) { if (DeviceObject.socKetClient.SendData(ref jsonStringBuilder)) { int state = DeviceObject.socKetClient.JsonRecive(jsonStringBuilder); if (state == 0) { _ResultInfo <DeviceInfo> deviceInfo = JsonConvert.DeserializeObject <_ResultInfo <DeviceInfo> >(jsonStringBuilder.ToString()); string deviceId = deviceInfo.result_data.deviceId; string deviceName = deviceInfo.result_data.name; txtMacSN.Text = deviceId; ret = true; Pub.MessageBoxShow(Pub.GetResText("", "MsgReadEndData", "")); } else { ret = false; msg = DeviceObject.socKetClient.GetStarState(state); } } else { ret = false; Pub.MessageBoxShow(Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", "")); } } else { ret = false; Pub.MessageBoxShow(Pub.GetResText("", "FK_RUNERR_NO_OPEN_COMM", "")); } DeviceObject.socKetClient.Close(); break; } if (ret) { Online = Pub.GetResText(formCode, "Online", ""); SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000300, new string[] { "304", Online , "", MacSN_GPRS })); } else { Online = Pub.GetResText(formCode, "Offline", ""); SystemInfo.db.ExecSQL(Pub.GetSQL(DBCode.DB_000300, new string[] { "305", Online, MacSN_GPRS })); } } catch (Exception E) { msg = E.Message; } this.Enabled = true; }
protected override void GetDelSql(int rowIndex, ref List <string> sql) { sql.Add(Pub.GetSQL(DBCode.DB_000205, new string[] { "1", dataGrid[1, rowIndex].Value.ToString() })); sql.Add(Pub.GetSQL(DBCode.DB_000205, new string[] { "2", dataGrid[1, rowIndex].Value.ToString() })); }
private bool CheckValue() { if (cbbMacType.Text == "") { MacSeriesTypeId = 0; MacSeriesTypeName = ""; } else { if (cbbMacType.Items.Count > 0) { MacSeriesTypeId = ((MacType)cbbMacType.SelectedItem).id; MacSeriesTypeName = ((MacType)cbbMacType.SelectedItem).name; } else { MacSeriesTypeId = 0; MacSeriesTypeName = ""; } } if (txtMacSN.Text.Trim() == "") { txtMacSN.Focus(); ShowErrorEnterCorrect(lblMacSN.Text); return(false); } if (rbLAN.Checked) { IsGPRS = chkGPRS.Checked; } if (!IsGPRS && !Pub.IsNumeric(txtMacSN.Text.Trim()) && MacSeriesTypeId != 3) { txtMacSN.Focus(); ShowErrorEnterCorrect(lblMacSN.Text); return(false); } if (IsGPRS || MacSeriesTypeId == 3) { MacSN_GPRS = txtMacSN.Text.Trim(); } else { MacSN = Convert.ToInt32(txtMacSN.Text.Trim()); MacSN_GPRS = MacSN.ToString(); } MacConnType = MacConnTypeString.USB; MacIP = ""; MacPort = ""; MacConnPWD = ""; MacDesc = ""; MacParamStr = ""; if (rbLAN.Checked) { MacConnType = MacConnTypeString.LAN; MacIP = txtLANIP.Text.Trim(); MacPort = txtLANPort.Text.Trim(); if (MacIP == "") { txtLANIP.Focus(); ShowErrorEnterCorrect(lblLANIP.Text); return(false); } if (!Pub.CheckTextMaxLength(lblLANIP.Text, MacIP, txtLANIP.MaxLength)) { txtLANIP.Focus(); return(false); } if (!Pub.IsNumeric(MacPort)) { txtLANPort.Focus(); ShowErrorEnterCorrect(lblLANPort.Text); return(false); } MacConnPWD = txtLANPWD.Text.Trim(); SeaSeriesPwd = txtLANPWD.Text.Trim(); if (MacSeriesTypeId != 2) { if (MacConnPWD != "" && !Pub.IsNumeric(MacConnPWD)) { txtLANPWD.Focus(); ShowErrorEnterCorrect(label3.Text); return(false); } } IsGPRS = chkGPRS.Checked; } MacDesc = txtDesc.Text.Trim(); if (!Pub.CheckTextMaxLength(label1.Text, MacDesc, txtDesc.MaxLength)) { txtDesc.Focus(); return(false); } MacModeID = cbbMacMode.SelectedIndex.ToString(); InOutMode = cbbInOutMode.SelectedIndex.ToString(); MacSeriesUserName = txtMacSeriesUserName.Text; return(true); }
protected override void GetDelSql(int rowIndex, ref List <string> sql) { string ret = Pub.GetSQL(DBCode.DB_002018, new string[] { "3", dataGrid[13, rowIndex].Value.ToString() }); sql.Add(ret); }
private void btnOk_Click(object sender, EventArgs e) { if (!db.CheckOprtRole(formCode, "M", true)) { return; } CurrentOprt = btnOk.Text; string T0 = txtTitle0.Text; string T1 = txtTitle1.Text; string T2 = txtTitle2.Text; string T3 = txtTitle3.Text; string T4 = txtTitle4.Text; int I0 = cbbOption0.SelectedIndex; int I1 = cbbOption1.SelectedIndex; int I2 = cbbOption2.SelectedIndex; int I3 = cbbOption3.SelectedIndex; int I4 = cbbOption4.SelectedIndex; if (!Pub.CheckTextMaxLength(label1.Text, T0, txtTitle0.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label2.Text, T1, txtTitle1.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label3.Text, T2, txtTitle2.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label4.Text, T3, txtTitle3.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label5.Text, T4, txtTitle4.MaxLength)) { return; } int PrintLine = 0; int.TryParse(txtLine.Text.Trim(), out PrintLine); if ((PrintLine < 0) || (PrintLine > 255)) { string msg = string.Format(Pub.GetResText(formCode, "Error001", ""), 0, 255); Pub.ShowErrorMsg(msg); return; } DataTableReader dr = null; string sql = ""; bool ret = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004002, new string[] { "0" })); if (dr.Read()) { sql = Pub.GetSQL(DBCode.DB_004002, new string[] { "2", T0, T1, T2, T3, T4, I0.ToString(), I1.ToString(), I2.ToString(), I3.ToString(), I4.ToString(), PrintLine.ToString() }); } else { sql = Pub.GetSQL(DBCode.DB_004002, new string[] { "1", T0, T1, T2, T3, T4, I0.ToString(), I1.ToString(), I2.ToString(), I3.ToString(), I4.ToString(), PrintLine.ToString() }); } db.ExecSQL(sql); byte[] buff = new byte[0]; if (picLogo.BackgroundImage != null) { MemoryStream ms = new MemoryStream(); picLogo.BackgroundImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); buff = ms.ToArray(); } db.UpdateByteData(Pub.GetSQL(DBCode.DB_004002, new string[] { "3" }), "PrintLogo", buff); ret = true; } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (ret) { db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
private void WriteCard() { ResetForm(); CurrentOprt = btnOk.Text; double money = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard()) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = sfData.BtMonery;// db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = ShowBTMoney.ToString(SystemInfo.CurrencySymbol + "0.00"); List <string> sql = new List <string>(); sql.Clear(); double mm = -money; double mmCZ = 0; double mmBT = 0; sfData.UseDate = dt; sfData.UseTimes += 1; if (rb1.Checked) { if (sfData.Balance < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.Balance -= money; mmCZ = -money; } else { if (sfData.BtMonery < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.BtMonery -= money; mmBT = -money; } double x = sfData.Balance + sfData.BtMonery; DataTableReader dr = null; string OpterStartDate = ""; string OpterEndDate = ""; DateTime StartDt = new DateTime(); DateTime EndDt = new DateTime(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "251", pubData.CardNo })); while (dr.Read()) { OpterStartDate = ""; OpterEndDate = ""; OpterStartDate = dr["OpterStartDate"].ToString(); OpterEndDate = dr["OpterEndDate"].ToString(); if (OpterStartDate != "") { StartDt = Convert.ToDateTime(OpterStartDate); } if (OpterEndDate != "") { EndDt = Convert.ToDateTime(OpterEndDate); } if (OpterStartDate != "" && OpterEndDate != "") { if (dt > StartDt && dt < EndDt) { break; } } else if (OpterStartDate != "" && OpterEndDate == "") { if (dt > StartDt) { OpterEndDate = dt.ToString(SystemInfo.SQLDateTimeFMT); break; } } } if (OpterStartDate != "") { OpterStartDate = Convert.ToDateTime(OpterStartDate).ToString(SystemInfo.SQLDateTimeFMT); } if (OpterEndDate != "") { OpterEndDate = Convert.ToDateTime(OpterEndDate).ToString(SystemInfo.SQLDateTimeFMT); } sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), mmCZ.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "", mmBT.ToString(), sfData.BtMonery.ToString(), "0", OpterStartDate, OpterEndDate })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money; double ReceivablesAmount = money; double CardBalance = x; string AmountTitle = label6.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } txtCardBalanceCZ.Text = sfData.Balance.ToString(SystemInfo.CurrencySymbol + "0.00"); txtCardBalanceBT.Text = sfData.BtMonery.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, CardBalance); db.WriteSYLog(this.Text, CurrentOprt, msg); DispExtScreen(Amount, CardBalance, 0, 0); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
protected override void ExecItemRefresh() { QuerySQL = Pub.GetSQL(DBCode.DB_002018, new string[] { "0", Pub.GetResText(formCode, "NormalRest", ""), Pub.GetResText(formCode, "TurnsoffRest", "") }); base.ExecItemRefresh(); }
private void WriteCard1() { ResetForm(1); double money = 0; double.TryParse(CurrencyToStringEx(txtMoney1.Text), out money); if (money <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } if (!ReadCard(1)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); if (!SystemInfo.AllowRefAllowance) { ShowBTMoney = 0; } double AllBalance = sfData.Balance + ShowBTMoney; textBox2.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); if (AllBalance < money) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorBalanceNotEnough", "")); return; } sfData.UseDate = dt; sfData.UseTimes += 1; List <string> sql = new List <string>(); sql.Clear(); if (ShowBTMoney == 0) { sfData.Balance -= money; if (sfData.BtMonery > 0 && SystemInfo.AllowRefAllowance) { double m = -sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "0", dt.ToString(SystemInfo.SQLDateTimeFMT), m.ToString(), sfData.Balance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); sfData.UseTimes += 1; sfData.BtMonery = 0; } } else { sfData.BtMonery -= money; if (sfData.BtMonery < 0) { sfData.Balance += sfData.BtMonery; sfData.BtMonery = 0; } } double mm = -money; AllBalance = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, "20", dt.ToString(SystemInfo.SQLDateTimeFMT), mm.ToString(), AllBalance.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, "" })); string Title = Pub.GetResText(formCode, "RefundmentTitle", ""); double Amount = money; double ReceivablesAmount = money; double CardBalance = AllBalance; string AmountTitle = label14.Text; if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + textBox8.Text + "]" + textBox9.Text + ": " + textBox5.Text + "/" + textBox7.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); textBox2.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); Pub.CardBuzzer(); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentTool, msg); DispExtScreen(Amount, temp, 1, 2); if (checkBox1.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult1.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private bool ReadCard(byte flag) { CardDepositLimit = 0; CardDepositTimes = 0; CardData10 = ""; CardDataH = ""; CardData8 = ""; if (!Pub.CheckCardExists(ref CardData10, ref CardDataH, ref CardData8)) { return(false); } pubData = new HSUNFK.TCardPubData(); sfData = new HSUNFK.TCardSFData(); if (!Pub.ReadCardInfo(ref pubData, ref sfData)) { return(false); } if (!db.CheckCardExists(pubData.CardNo, CardData10)) { return(false); } DateTime dt = new DateTime(); if (!db.GetServerDate(ref dt)) { return(false); } if (!Pub.CheckCardValidDate(dt, pubData.CardBeginDate, pubData.CardEndDate)) { return(false); } DataTableReader dr = null; bool IsOk = false; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (!db.CheckDepartPowerByCard(pubData.CardNo)) { return(false); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_001003, new string[] { "215", pubData.CardNo })); if (dr.Read()) { if (Convert.ToInt32(dr["CardStatusID"]) != 20) { if (flag == 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardDepositNotNormal", "")); } else { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardRefunNotNormal", "")); } } else if (flag != 0 && !Convert.ToBoolean(dr["CardRefundment"].ToString())) { Pub.ShowErrorMsg(string.Format(Pub.GetResText("", "ErrorCardRefundment", ""), dr["CardTypeName"].ToString())); } else { IsOk = true; if (flag == 0) { txtEmpNo.Text = dr["EmpNo"].ToString(); txtEmpName.Text = dr["EmpName"].ToString(); txtDepartName.Text = dr["DepartName"].ToString(); txtCardSectorNo.Text = dr["CardSectorNo"].ToString(); txtCardStatusName.Text = dr["CardStatusName"].ToString(); txtCardType.Text = dr["CardTypeName"].ToString(); int.TryParse(dr["DepositDiscount"].ToString(), out Discount); txtDepositDiscount.Text = Discount.ToString(); double.TryParse(dr["CardDepositLimit"].ToString(), out CardDepositLimit); int.TryParse(dr["CardDepositTimes"].ToString(), out CardDepositTimes); } else { if (ExistsDepositType) { string SFTypeName = ""; double SFAmount = 0; IsOk = db.SFGetLastSFType(dr["EmpSysID"].ToString(), ref SFTypeName, ref SFAmount); if (IsOk && (SFTypeName != "")) { txtUpDepositType.Text = SFTypeName + ":" + SFAmount.ToString(SystemInfo.CurrencySymbol + "0.00"); } } if (IsOk) { textBox8.Text = dr["EmpNo"].ToString(); textBox9.Text = dr["EmpName"].ToString(); textBox7.Text = dr["DepartName"].ToString(); textBox5.Text = dr["CardSectorNo"].ToString(); textBox6.Text = dr["CardStatusName"].ToString(); textBox4.Text = dr["CardTypeName"].ToString(); } } } } else { Pub.ShowErrorMsg(Pub.GetResText("", "ErrorIllegalCard", "")); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } return(IsOk); }
protected override void InitForm() { formCode = "SFDepositRef"; base.InitForm(); this.Toolbar.Visible = false; this.Statusbar.Visible = false; Font fnt = new Font(this.Font.FontFamily, 20); txtMoney.Enter += TextBoxCurrency_Enter; txtMoney.Leave += TextBoxCurrency_Leave; txtMoney1.Enter += TextBoxCurrency_Enter; txtMoney1.Leave += TextBoxCurrency_Leave; double d = SystemInfo.DefDepositMoney; txtMoney.Text = d.ToString(SystemInfo.CurrencySymbol + "0.00"); d = 0; txtMoney1.Text = d.ToString(SystemInfo.CurrencySymbol + "0.00"); ResetForm(0); ResetForm(1); ExistsDepositType = SystemInfo.HasMoreDepositType; if (ExistsDepositType) { cbbType.Items.Clear(); DataTableReader dr = null; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004013, new string[] { "102" })); dr.Read(); cbbType.Items.Add(new TCommonType(dr["SFTypeSysID"].ToString(), dr["SFTypeID"].ToString(), dr["SFTypeName"].ToString(), true)); dr.Close(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004013, new string[] { "0" })); while (dr.Read()) { cbbType.Items.Add(new TCommonType(dr["GUID"].ToString(), dr["DepositTypeID"].ToString(), dr["DepositTypeName"].ToString(), true)); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (cbbType.Items.Count > 0) { cbbType.SelectedIndex = 0; } if (cbbType.Items.Count == 1) { ExistsDepositType = false; } } cbbType.Enabled = ExistsDepositType; cbbType.Visible = cbbType.Enabled; label10.Visible = cbbType.Enabled; txtUpDepositType.Enabled = ExistsDepositType; txtUpDepositType.Visible = txtUpDepositType.Enabled; lblUpDepositType.Visible = txtUpDepositType.Enabled; txtMoney.Focus(); toolTip.SetToolTip(picDisc, Pub.GetResText(formCode, "DiscHint", "")); OkContinue = SystemInfo.ini.ReadIni("Public", "CardOk", true); chkPrint.Checked = SystemInfo.ini.ReadIni("Public", "CheckPrint", false); checkBox1.Checked = SystemInfo.ini.ReadIni("Public", "CheckPrint1", false); MobileInfo = new TMobileInfo(""); DeviceObject.objCard.MobileInit(MobileInfo.MobTyp, MobileInfo.MercID, MobileInfo.TrmNo, MobileInfo.PWD, MobileInfo.XJLName, MobileInfo.XJLPWD); }
private void WriteCard() { ResetForm(0); string AmountTitle = label7.Text; string DepositType = "10"; string TradeNo = ""; if (ExistsDepositType) { DepositType = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).id; AmountTitle = cbbType.Text; } double money = 0; double Fact = 0; double DiscountMoney = 0; int DiscountType = 0; double.TryParse(CurrencyToStringEx(txtMoney.Text), out money); if (money <= 0) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMoneyZero", "")); return; } double MobileMoney = money; if (!SystemInfo.IgnoreMobile && (DepositType == "100" || DepositType == "101")) { money -= MobileInfo.RateMoney(DepositType == "100", MobileMoney); } Fact = money; if (!ReadCard(0)) { return; } DateTime dt = new DateTime(); if (!db.GetServerDate(this.Text, ref dt)) { return; } if (!Pub.CheckUseDate(dt, sfData.UseDate)) { return; } Pub.ClearCardLimitInfo(dt, ref sfData); double ShowBTMoney = db.GetBTMoney(sfData.BtDate, sfData.BtMonery); double AllBalance = sfData.Balance + ShowBTMoney; txtCardBalance.Text = AllBalance.ToString(SystemInfo.CurrencySymbol + "0.00"); double tmpMoney = 0; byte discFlag = db.GetDiscDiscount(money, pubData.CardTypeID, ref tmpMoney); if (discFlag == 2) { return; } if (discFlag == 1) { DiscountMoney = tmpMoney; Fact = money + DiscountMoney; DiscountType = 80; } else if ((Discount > 0) && (Discount != 100)) { DiscountMoney = money * Discount / 100; DiscountMoney = DiscountMoney - money; Fact = money + DiscountMoney; if (DiscountMoney > 0) { DiscountType = 80; } else { DiscountType = 70; } } if (AllBalance + Fact > SystemInfo.MaxDeposit) { Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBig", ""), SystemInfo.MaxDeposit)); return; } if (SystemInfo.AllowCheckDepositLimit == 1) { if (CardDepositLimit > 0 && sfData.Balance + Fact >= CardDepositLimit) { Pub.ShowErrorMsg(string.Format(Pub.GetResText(formCode, "ErrorBalanceIsBigA", ""), CardDepositLimit)); return; } } if (!SystemInfo.IgnoreMobile && (DepositType == "100" || DepositType == "101")) { int h = SystemInfo.MainHandle.ToInt32(); bool IsWeiXin = DepositType == "100"; bool IsPayM = false; string ErrMsg = ""; if (!DeviceObject.objCard.MobileShow(h, CardData10, pubData.CardNo, MobileMoney, ref IsWeiXin, ref IsPayM, true, ref TradeNo, ref ErrMsg)) { Pub.ShowErrorMsg(ErrMsg); return; } DepositType = IsWeiXin ? "100" : "101"; } List <string> sql = new List <string>(); sql.Clear(); string Title = Pub.GetResText(formCode, "DepositTitle", ""); double Amount = money; double ReceivablesAmount = Fact; double CardBalance = AllBalance + Fact; sfData.Balance = sfData.Balance + money; sfData.UseTimes = sfData.UseTimes + 1; sfData.UseDate = dt; double mm = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DepositType, dt.ToString(SystemInfo.SQLDateTimeFMT), money.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, TradeNo, "0", sfData.BtMonery.ToString(), "0" })); if (DiscountMoney != 0) { sfData.Balance = sfData.Balance + DiscountMoney; sfData.UseTimes = sfData.UseTimes + 1; mm = sfData.Balance + sfData.BtMonery; sql.Add(Pub.GetSQL(DBCode.DB_004005, new string[] { "0", pubData.CardNo, DiscountType.ToString(), dt.AddSeconds(1).ToString(SystemInfo.SQLDateTimeFMT), DiscountMoney.ToString(), mm.ToString(), "0", "", "0", sfData.UseTimes.ToString(), OprtInfo.OprtSysID, "", "1", "", CardData10, pubData.MacTAG, TradeNo, "0", sfData.BtMonery.ToString(), "0" })); } if (db.ExecSQL(sql) != 0) { return; } int cardRet = 0; string CardNo10 = ""; string CardNoH = ""; string CardNo8 = ""; bool IsSFError = false; string msg = "[" + txtEmpNo.Text + "]" + txtEmpName.Text + ": " + txtCardSectorNo.Text + "/" + txtDepartName.Text; ContinueSF: Application.DoEvents(); if (IsSFError) { CardNo10 = ""; CardNoH = ""; CardNo8 = ""; if (!Pub.CheckCardExists(ref CardNo10, ref CardNoH, ref CardNo8, false)) { lblResult.Text = Pub.GetResText(formCode, "ReadCardError3", ""); goto ContinueSF; } if (CardNo10 != CardData10) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "MsgCardSame", "") + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetResText(formCode, "MsgCardSame", ""))) { return; } else { goto ContinueSF; } } } IsSFError = false; } cardRet = Pub.WriteCardInfo(sfData); if (cardRet != 0) { if (OkContinue) { Pub.ShowErrorMsg(Pub.GetCardMsg(cardRet) + "\r\n\r\n" + Pub.GetResText(formCode, "MsgCardOkContinue", "")); IsSFError = true; goto ContinueSF; } else { if (Pub.MessageBoxShowQuestion(Pub.GetCardMsg(cardRet) + Pub.GetResText(formCode, "MsgContinue", ""))) { return; } else { IsSFError = true; goto ContinueSF; } } } double temp = sfData.Balance + db.GetBTMoney(sfData.BtDate, sfData.BtMonery); txtCardBalance.Text = temp.ToString(SystemInfo.CurrencySymbol + "0.00"); msg = msg + string.Format("[{0:f2},{1:f2}]", Amount, temp); db.WriteSYLog(this.Text, CurrentTool, msg); Pub.CardBuzzer(); DispExtScreen(Amount, temp, 0, 1); if (chkPrint.Checked) { PrintCardBill(Title, Amount, ReceivablesAmount, CardBalance, AmountTitle, pubData.CardNo); } lblResult.Text = this.Text + Pub.GetResText(formCode, "MsgSuccess", ""); }
private void LoadData() { cbbType.Items.Clear(); TCommonType ctype; DataTableReader dr = null; try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002002, new string[] { "200" })); while (dr.Read()) { ctype = new TCommonType(dr["TripTypeSysID"].ToString(), dr["TripTypeNo"].ToString(), dr["TripTypeName"].ToString(), true); cbbType.Items.Add(ctype); } if (SysID == "") { if (cbbType.Items.Count > 0) { cbbType.SelectedIndex = 0; } txtNo.Text = GetBillNo(); } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002009, new string[] { "5", SysID })); if (dr.Read()) { txtNo.Text = dr["TripBillNo"].ToString(); txtEmpNo.Text = dr["EmpNo"].ToString(); txtEmpNo.Tag = dr["EmpSysID"].ToString(); txtEmpName.Text = dr["EmpName"].ToString(); txtDepart.Text = "[" + dr["DepartID"].ToString() + "]" + dr["DepartName"].ToString(); DateTime dt = new DateTime(); DateTime.TryParse(dr["TripStartDate"].ToString(), out dt); string[] tt = dr["TripStartTime"].ToString().Split(':'); dt = dt.AddHours(Convert.ToDouble(tt[0])).AddMinutes(Convert.ToDouble(tt[1])); dtpStart.Value = dt; DateTime.TryParse(dr["TripEndDate"].ToString(), out dt); tt = dr["TripEndTime"].ToString().Split(':'); dt = dt.AddHours(Convert.ToDouble(tt[0])).AddMinutes(Convert.ToDouble(tt[1])); dtpEnd.Value = dt; for (int i = 0; i < cbbType.Items.Count; i++) { if (((TCommonType)cbbType.Items[i]).sysID == dr["TripTypeSysID"].ToString()) { cbbType.SelectedIndex = i; break; } } txtReason.Text = dr["TripReason"].ToString(); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } }
protected override void ExecItemRefresh() { QuerySQL = Pub.GetSQL(DBCode.DB_000205, new string[] { "0" }); base.ExecItemRefresh(); }
public void ShowRealData(QHKS.TMJRecordInfo recInfo, string MacSN) { string EmpSysID = ""; string EmpNo = ""; string EmpName = ""; string DepartID = ""; string DepartName = ""; string CardSectorNo = ""; string MacDoorName = ""; string MacPassState = Pub.GetResText(formCode, "AllowPass", ""); string MacReadImpact = ""; string Memo = ""; string readerid = Pub.GetMJReaderID(MacSN, recInfo.ReaderID); string wavFile = ""; DataTableReader dr = null; try { if (recInfo.IsCard == 1) { if (SystemInfo.CardProtocol == 0) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "0", recInfo.CardNo })); } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "1", recInfo.CardNo })); } if (dr.Read()) { EmpSysID = dr["EmpSysID"].ToString(); EmpNo = dr["EmpNo"].ToString(); EmpName = dr["EmpName"].ToString(); DepartID = dr["DepartID"].ToString(); DepartName = dr["DepartName"].ToString(); if (SystemInfo.HasFaCard) { CardSectorNo = dr["CardSectorNo"].ToString(); } else { CardSectorNo = dr["CardPhysicsNo10"].ToString(); } } dr.Close(); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "2", MacSN, readerid })); if (dr.Read()) { MacDoorName = dr["MacDoorName"].ToString(); MacReadImpact = dr["MacReadImpact"].ToString(); } } catch { } finally { if (dr != null) { dr.Close(); } dr = null; } if ((EmpSysID == "") || (recInfo.IsPass == 0)) { int IndexNum = recInfo.AlarmType; if (recInfo.IsCard == 1) { IndexNum = 144; } Memo = Pub.GetResText(formCode, "MJRecordMemo" + IndexNum.ToString(), ""); if (recInfo.IsCard == 1) { Memo += "[" + recInfo.CardNo + "]"; wavFile = "PassDis.wav"; } else if (IndexNum == 140) { wavFile = "NormalIn.wav"; } else if (IndexNum == 141) { wavFile = "AlarmDur.wav"; } else if (IndexNum == 142) { wavFile = "DoorTime.wav"; } else if ((IndexNum == 143) || (IndexNum == 145) || (IndexNum == 146)) { wavFile = "Alarm.wav"; } else if (IndexNum == 148) { wavFile = "AlarmDis.wav"; } if (wavFile != "") { wavFile = wavPath + wavFile; Pub.PlaySound(wavFile); } alarmGrid.Rows.Add(); while (alarmGrid.RowCount > maxCount) { alarmGrid.Rows.RemoveAt(0); } alarmGrid[0, alarmGrid.RowCount - 1].Value = recInfo.CardTime; alarmGrid[1, alarmGrid.RowCount - 1].Value = MacSN; alarmGrid[2, alarmGrid.RowCount - 1].Value = MacDoorName; alarmGrid[3, alarmGrid.RowCount - 1].Value = readerid; alarmGrid[4, alarmGrid.RowCount - 1].Value = IndexNum; alarmGrid[5, alarmGrid.RowCount - 1].Value = Memo; alarmGrid.Rows[alarmGrid.RowCount - 1].Selected = true; alarmGrid.CurrentCell = alarmGrid.Rows[alarmGrid.RowCount - 1].Cells[0]; tabControl1.SelectedIndex = 1; } else { if (MacReadImpact.ToLower() == "in") { wavFile = "NormalIn.wav"; } else { wavFile = "NormalIn.wav"; } wavFile = wavPath + wavFile; Pub.PlaySound(wavFile); realGrid.Rows.Add(); while (realGrid.RowCount > maxCount) { realGrid.Rows.RemoveAt(0); } realGrid[0, realGrid.RowCount - 1].Value = CardSectorNo; realGrid[1, realGrid.RowCount - 1].Value = recInfo.CardTime; realGrid[2, realGrid.RowCount - 1].Value = EmpNo; realGrid[3, realGrid.RowCount - 1].Value = EmpName; realGrid[4, realGrid.RowCount - 1].Value = DepartID; realGrid[5, realGrid.RowCount - 1].Value = DepartName; realGrid[6, realGrid.RowCount - 1].Value = MacSN; realGrid[7, realGrid.RowCount - 1].Value = MacDoorName; realGrid[8, realGrid.RowCount - 1].Value = MacPassState; realGrid[9, realGrid.RowCount - 1].Value = MacReadImpact; realGrid[10, realGrid.RowCount - 1].Value = EmpSysID; realGrid.Rows[realGrid.RowCount - 1].Selected = true; realGrid.CurrentCell = realGrid.Rows[realGrid.RowCount - 1].Cells[0]; if (realGrid.RowCount == 1) { realGrid_SelectionChanged(null, null); } tabControl1.SelectedIndex = 0; } if (isSaveDB) { SaveDB(recInfo, MacSN); } }
private void LoadData() { DataTableReader dr = null; try { if (SysID == "") { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "103" })); if (dr.Read()) { int no = 0; int.TryParse(dr[0].ToString(), out no); if (no == 0) { no++; } txtMacSN.Text = no.ToString(); } } else { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "2", SysID })); if (dr.Read()) { txtMacSN.Text = dr["MacSN"].ToString(); txtDevGroup.Text = dr["DevGroupName"].ToString(); txtDevGroup.Tag = dr["DevGroupID"].ToString(); int id = 0; Int32.TryParse(dr["MacSeriesTypeId"].ToString(), out id); int InOutModeId = 0; Int32.TryParse(dr["InOutMode"].ToString(), out InOutModeId); cbbInOutMode.SelectedIndex = InOutModeId; int DevModeId = 0; Int32.TryParse(dr["DevModeID"].ToString(), out DevModeId); cbbMacMode.SelectedIndex = DevModeId; MacType type = GetMacType(id); if (type != null) { cbbMacType.SelectedItem = type; } switch (dr["MacConnType"].ToString()) { case MacConnTypeString.USB: rbUSB.Checked = true; break; case MacConnTypeString.LAN: rbLAN.Checked = true; txtLANIP.Text = dr["MacIP"].ToString(); txtLANPort.Text = dr["MacPort"].ToString(); txtLANPWD.Text = dr["MacConnPWD"].ToString(); chkGPRS.Checked = Pub.ValueToBool(dr["IsGPRS"]); break; } txtDesc.Text = dr["MacDesc"].ToString(); } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } }
private void SaveDB(QHKS.TMJRecordInfo recInfo, string MacSN) { DateTime t = recInfo.CardTime; int MJTime = t.Hour * 60 * 60 + t.Minute * 60 + t.Second; string memo = ""; string sql = ""; if (recInfo.IsCard == 0) { memo = Pub.GetResText("", "MJRecordMemo" + recInfo.AlarmType.ToString(), ""); sql = Pub.GetSQL(DBCode.DB_003005, new string[] { "1", t.ToString(SystemInfo.SQLDateFMT), MJTime.ToString(), MacSN, recInfo.DoorID.ToString(), recInfo.AlarmType.ToString(), memo, OprtInfo.OprtSysID }); } else { memo = Pub.GetResText("", "MJRecordMemo144", "") + "[" + recInfo.CardNo + "]"; string IsPass = "******"; if (recInfo.IsPass == 1) { IsPass = "******"; } sql = Pub.GetSQL(DBCode.DB_003005, new string[] { "0", SystemInfo.CardProtocol.ToString(), recInfo.CardNo, t.ToString(SystemInfo.SQLDateFMT), MJTime.ToString(), MacSN, Pub.GetMJReaderID(MacSN, recInfo.ReaderID), OprtInfo.OprtSysID, memo, IsPass }); } try { db.ExecSQL(sql); } catch (Exception E) { Pub.ShowErrorMsg(E, sql); return; } db.WriteSYLog(this.Text, CurrentTool, sql); }
protected override void InitForm() { formCode = "MacInfoAdd"; base.InitForm(); this.Text = Title + "[" + CurrentOprt + "]"; lblMacSN.ForeColor = Color.Red; lblLANIP.ForeColor = Color.Red; lblLANPort.ForeColor = Color.Red; lbMsgGetMacNo.Text = string.Format(Pub.GetResText("", "MsgGetMacNo", ""), Pub.GetResText("", "SeaDev", "")); SetTextboxNumber(txtLANPort); cbbMacType.Items.AddRange(new object[] { new MacType(1, Pub.GetResText("", "StaticDev", "")) }); if (SystemInfo.ShowSEA == 1) { cbbMacType.Items.AddRange(new object[] { new MacType(2, Pub.GetResText("", "SeaDev", "")) }); } if (SystemInfo.ShowSTAR == 1) { cbbMacType.Items.AddRange(new object[] { new MacType(3, Pub.GetResText("", "StarDev", "")) }); } cbbInOutMode.Items.AddRange(new object[] { Pub.GetResText("", "LOG_IOMODE_IO", ""), Pub.GetResText("", "LOG_IOMODE_IN1", ""), Pub.GetResText("", "LOG_IOMODE_OUT1", ""), }); cbbInOutMode.SelectedIndex = 0; cbbMacMode.Items.AddRange(new object[] { Pub.GetResText("", "LOG_DEVMODE_KQMJ", ""), Pub.GetResText("", "LOG_DEVMODE_KQ", ""), Pub.GetResText("", "LOG_DEVMODE_MJ", ""), }); if (SystemInfo.AllowMJ) { cbbMacMode.SelectedIndex = 0; cbbMacType.Visible = true; lbMacType.Visible = true; txtMacSeriesUserName.Visible = true; lbMacSeriesUserName.Visible = true; cbbMacMode.Enabled = true; } else { cbbMacMode.SelectedIndex = 1; cbbMacType.Visible = false; lbMacType.Visible = false; txtMacSeriesUserName.Visible = false; lbMacSeriesUserName.Visible = false; cbbMacMode.Enabled = false; } int index = 0; if (cbbMacType.Items.Count > 0) { cbbMacType.SelectedIndex = 0; index = ((MacType)cbbMacType.SelectedItem).id; } switch (index) { case 2: txtMacSeriesUserName.Visible = true; lbMacSeriesUserName.Visible = true; cbbInOutMode.Visible = true; chkGPRS.Visible = false; pnlLAN.Height = 95; panel6.Height = 300; this.Height = 30 + panel6.Height + panel5.Height + panel4.Height; panel4.Visible = true; label2.Visible = true; break; case 3: txtMacSeriesUserName.Visible = false; lbMacSeriesUserName.Visible = false; cbbInOutMode.Visible = false; chkGPRS.Visible = true; pnlLAN.Height = 63; panel6.Height = 270; panel4.Visible = false; this.Height = 30 + panel6.Height + panel5.Height; label2.Visible = false; break; default: txtMacSeriesUserName.Visible = false; lbMacSeriesUserName.Visible = false; cbbInOutMode.Visible = false; chkGPRS.Visible = true; panel4.Visible = false; pnlLAN.Height = 63; panel6.Height = 270; this.Height = 30 + panel6.Height + panel5.Height; label2.Visible = false; break; } LoadData(); RadioButton_Click(null, null); }
public void CheckInTest_2男1女_與ICheckInFee互動2次() { //arrange mock var customers = new List<Customer>(); //2男1女 var customer1 = new Customer { IsMale = true, Seq = 1 }; var customer2 = new Customer { IsMale = false, Seq = 2 }; var customer3 = new Customer { IsMale = true, Seq = 3 }; customers.Add(customer1); customers.Add(customer2); customers.Add(customer3); MockRepository mock = new MockRepository(); ICheckInFee stubCheckInFee = mock.StrictMock<ICheckInFee>(); using (mock.Record()) { //期望呼叫ICheckInFee的GetFee()次數為2次 //且第一次的參數為customer1, 第二次的參數為customer3 stubCheckInFee.GetFee(customer1); LastCall .Return((decimal)100); stubCheckInFee.GetFee(customer3); LastCall .Return((decimal)200); ////若不需要檢查傳入參數,只需要確認呼叫次數為2次,可以這樣寫 //stubCheckInFee.GetFee(customer1); //LastCall // .IgnoreArguments().Return((decimal)200) // .Repeat.Times(2); } using (mock.Playback()) { var target = new Pub(stubCheckInFee); var count = target.CheckIn(customers); } }
private void btnOk_Click(object sender, EventArgs e) { DataTableReader dr = null; bool IsOk = false; string sql = ""; if (txtDevGroup.Text == "") { MacDevGroupID = ""; } if (!CheckValue()) { return; } try { if (SysID == "") { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "2", MacSN_GPRS })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "3", MacSN_GPRS, SystemInfo.MacTypeID.ToString(), "", MacConnType, MacIP, MacPort, MacConnPWD, MacDesc, MacParamStr, Convert.ToByte(IsGPRS).ToString(), MacSeriesTypeId.ToString(), MacSeriesTypeName, MacSeriesUserName, InOutMode, MacDevGroupID, txtDevGroup.Text, MacModeID }); SystemInfo.db.ExecSQL(sql); IsOk = true; } } else { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "4", SysID, MacSN_GPRS })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "5", MacSN_GPRS, SystemInfo.MacTypeID.ToString(), "", MacConnType, MacIP, MacPort, MacConnPWD, MacDesc, MacParamStr, Convert.ToByte(IsGPRS).ToString(), MacSeriesTypeId.ToString(), MacSeriesTypeName, MacSeriesUserName, InOutMode, MacDevGroupID, txtDevGroup.Text, MacModeID, SysID }); SystemInfo.db.ExecSQL(sql); IsOk = true; } if (IsOk) { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000002, new string[] { "201", SysID })); if (dr.Read()) { sql = Pub.GetSQL(DBCode.DB_000002, new string[] { "204", SysID, MacSN_GPRS, "", "", "" }); SystemInfo.db.ExecSQL(sql); } } } } catch (Exception E) { Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { SystemInfo.db.WriteSYLog(this.Text, CurrentOprt, sql); //Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
/// <summary> /// 开始群发邮件 /// </summary> /// <param name="msg"></param> /// <param name="done"></param> public static void Start(Action<string> msg = null, Pub.Class.Action done = null) { ServicePointManager.DefaultConnectionLimit = 10000; mailer.Start(msg, done); }
protected override void ExecItemRefresh() { string SFType = ""; string MacSN = ""; string AddressTag = "0"; string AddressID = ""; string AddressList = ""; if (chkSFType.Checked) { for (int i = 0; i < clbSFType.Items.Count; i++) { if (clbSFType.GetItemChecked(i)) { SFType = SFType + ((TCommonType)clbSFType.Items[i]).id + ","; } } if (SFType != "") { SFType = SFType.Substring(0, SFType.Length - 1); } } if (chkMacSN.Checked) { for (int i = 0; i < clbMacSN.Items.Count; i++) { if (clbMacSN.GetItemChecked(i)) { MacSN = MacSN + "'" + clbMacSN.Items[i].ToString() + "',"; } } if (MacSN != "") { MacSN = MacSN.Substring(0, MacSN.Length - 1); } } if ((txtAddress.Text.Trim() != "") && (txtAddress.Tag != null)) { AddressID = txtAddress.Tag.ToString(); AddressTag = "1"; } else if (txtAddress.Text.Trim() != "") { AddressID = txtAddress.Text.Trim(); } if (AddressTag == "1") { if (AddressID != "") { AddressList = db.GetAddressChildID(AddressID); } if (AddressList == "") { AddressList = "''"; } } QuerySQL = Pub.GetSQL(DBCode.DB_004011, new string[] { "4", SFType, MacSN, dtpStart.Value.ToString(SystemInfo.SQLDateTimeFMT), dtpEnd.Value.ToString(SystemInfo.SQLDateTimeFMT), AddressTag, AddressID, AddressList }); SetReportDate(dispView, label4.Text + ": " + dtpStart.Value.ToString() + " - " + dtpEnd.Value.ToString()); base.ExecItemRefresh(); SetReportTitle(dispView, this.Text); }
private void LoadData() { DataTableReader dr = null; string printStr = ""; MemoryStream logo = new MemoryStream(); try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_004004, new string[] { "7", SysID })); if (dr.Read()) { printStr = dr["PrintTitle"].ToString(); if (dr["PrintLogo"].ToString() != "") { byte[] buff = (byte[])(dr["PrintLogo"]); if (buff.Length > 0) { logo = new MemoryStream(buff); } } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } TPrintTitleInfo info = new TPrintTitleInfo(printStr); int i; Label lbl; gbxTitle.Text = Pub.GetResText("SFPrintTitle", gbxTitle.Name, ""); for (i = 1; i <= 6; i++) { lbl = ((Label)gbxTitle.Controls["label" + i.ToString()]); if (lbl != null) { lbl.Text = Pub.GetResText("SFPrintTitle", lbl.Name, ""); toolTip.SetToolTip(lbl, lbl.Text); } } gbxLogo.Text = Pub.GetResText("SFPrintTitle", gbxLogo.Name, ""); button1.Text = Pub.GetResText("SFPrintTitle", button1.Name, ""); button2.Text = Pub.GetResText("SFPrintTitle", button2.Name, ""); label6.Text = Pub.GetResText("SFPrintTitle", label6.Name, ""); TextBox txt; ComboBox cbb; for (i = 0; i < 5; i++) { txt = ((TextBox)gbxTitle.Controls["txtTitle" + i.ToString()]); if (txt != null) { txt.Text = info.Title[i]; } cbb = ((ComboBox)gbxTitle.Controls["cbbOption" + i.ToString()]); if (cbb == null) { continue; } cbb.Items.Clear(); for (int j = 0; j < 5; j++) { cbb.Items.Add(Pub.GetResText("SFPrintTitle", "PrintOption" + j.ToString(), "")); } if (cbb.Items.Count > 0) { cbb.SelectedIndex = info.Zoom[i]; } } if (logo.Length > 0) { picLogo.BackgroundImage = Image.FromStream(logo); } else if (info.Logo.Length > 0) { picLogo.BackgroundImage = Image.FromStream(info.Logo); } txtLine.Text = info.Line.ToString(); }
private void btnOk_Click(object sender, EventArgs e) { if (!CheckEmp()) { return; } if (dtpStart.Value > dtpEnd.Value) { dtpStart.Focus(); Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorStartTimeBegreater", "")); return; } if (cbbType.SelectedIndex == -1) { cbbType.Focus(); ShowErrorSelectCorrect(label7.Text); return; } string BillNo = txtNo.Text; string EmpSysID = txtEmpNo.Tag.ToString(); string TypeSysID = ((TCommonType)cbbType.Items[cbbType.SelectedIndex]).sysID; string Reason = txtReason.Text.Trim(); if (!Pub.CheckTextMaxLength(label8.Text, Reason, txtReason.MaxLength)) { return; } List <string> sql = new List <string>(); int days = (int)Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date); DataTableReader dr = null; bool IsError = false; bool IsExists = true; try { if (SysID == "") { while (IsExists) { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002009, new string[] { "6", BillNo })); if (!dr.Read()) { IsExists = false; } dr.Close(); if (IsExists) { BillNo = GetBillNo(); } } GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql); if (cardGrid.DataSource != null) { DataTable dtGrid = (DataTable)cardGrid.DataSource; for (int i = 0; i < dtGrid.Rows.Count; i++) { if (dtGrid.Rows[i]["EmpSysID"].ToString() == EmpSysID) { continue; } GetSql(days, dtGrid.Rows[i]["EmpSysID"].ToString(), BillNo, TypeSysID, Reason, ref sql); } } } else { GetSql(days, EmpSysID, BillNo, TypeSysID, Reason, ref sql); } } catch (Exception E) { IsError = true; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsError) { return; } if (db.ExecSQL(sql) != 0) { return; } db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); }
private bool CheckValue() { if (!Pub.CheckTextMaxLength(lblMacSN.Text, txtMacSN.Text, txtMacSN.MaxLength)) { txtMacSN.Focus(); return(false); } if ((txtMacSN.Text == "") || !Pub.IsNumeric(txtMacSN.Text)) { txtMacSN.Focus(); ShowErrorEnterCorrect(lblMacSN.Text); return(false); } MacSN = txtMacSN.Text.Trim(); if (MacSN.Length != 7) { txtMacSN.Focus(); ShowErrorEnterCorrect(lblMacSN.Text); return(false); } MacDoorType = Convert.ToByte(MacSN.Substring(1, 1)); if ((MacDoorType != 1) && (MacDoorType != 2) && (MacDoorType != 4)) { txtMacSN.Focus(); ShowErrorEnterCorrect(lblMacSN.Text); return(false); } MacConnType = MacConnTypeString.USB; MacIPAddress = ""; MacPort = ""; MacConnPWD = ""; MacDesc = ""; if (rbComm.Checked) { MacConnType = MacConnTypeString.Comm; MacPort = cbbCommPort.Text; MacConnPWD = "19200"; if (MacPort == "") { ShowErrorSelectCorrect(lblCommPort.Text); return(false); } } else if (rbLAN.Checked) { MacConnType = MacConnTypeString.LAN; MacIPAddress = txtLANIP.Text.Trim(); MacPort = txtLANPort.Text.Trim(); if (MacIPAddress == "") { txtLANIP.Focus(); Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMacIP", "")); return(false); } if (!Pub.CheckTextMaxLength(lblLANIP.Text, MacIPAddress, txtLANIP.MaxLength)) { txtLANIP.Focus(); return(false); } if (!Pub.IsNumeric(MacPort)) { txtLANPort.Focus(); Pub.ShowErrorMsg(Pub.GetResText(formCode, "ErrorMacPort", "")); return(false); } } MacDesc = txtDesc.Text.Trim(); if (!Pub.CheckTextMaxLength(label1.Text, MacDesc, txtDesc.MaxLength)) { txtDesc.Focus(); return(false); } return(true); }
protected override void OnInit(EventArgs e) { base.OnInit(e); gstrSessionID = ""; //if (base.Request.Cookies["ASP.NET_SessionId"] != null) gstrSessionID = base.Request.Cookies["ASP.NET_SessionId"].Value; //base.Response.AddHeader("<Debug>Cookie_Old", SessionID); ////base.Response.Cookies["ASP.NET_SessionId_Request"].Value = base.Request.Headers.Count.ToString(); //for (int i = 0; i < base.Request.Headers.Count; i++) { // string szName = base.Request.Headers.GetKey(i); // string szDebug = "<Debug>" + base.Request.Headers.GetKey(i); // string szValue = ""; // if (szName == "Azalea_SessionID") { // for (int j = 0; j < base.Request.Headers.GetValues(i).Length; j++) { // string sVal = base.Request.Headers.GetValues(i)[j]; // szValue += sVal; // } // gstrSessionID = szValue; // } // //base.Response.Write(base.Request.Headers.GetKey(i) + ":"); // base.Response.AddHeader(szDebug, szValue); //} if (gstrSessionID == "") { gstrSessionID = Pub.Request(this, "Azalea_SessionID"); } glngAuthorizeID = dyk.Type.String.New(Pub.Request(this, "Azalea_AuthID")).ToNumber; // //base.Response.Write(base.Request.Headers.GetKey(i) + ":"); // for (int j = 0; j < base.Request.Headers.GetValues(i).Length; j++) { // //base.Response.Write("[" + j + "]" + base.Request.Headers.GetValues(i)[j]); // //base.Response.AddHeader("<Debug>Request_" + base.Request.Headers.GetKey(i) + "[" + j + "]", base.Request.Headers.GetValues(i)[j]); // if (base.Request.Headers.GetKey(i).ToLower() == "cookie") { // //base.Response.AddHeader("<Debug>Cookie", "Found"); // string sVal = base.Request.Headers.GetValues(i)[j]; // string[] sVals = sVal.Split(';'); // //base.Response.AddHeader("<Debug>Cookie", sVals.Length.ToString()); // for (int s = 0; s < sVals.Length; s++) { // if (sVals[s].Trim() != "") { // string[] sSubVals = sVals[s].Split('='); // if (sSubVals.Length == 2) { // string sName = sSubVals[0].Trim(',').Trim().ToLower(); // string sTemp = ""; // //base.Response.AddHeader("<Debug>Cookie", "Found\"=\""); // for (int n = 0; n < sName.Length; n++) { // sTemp += "[" + sName[n] + "," + (int)sName[n] + "]"; // } // base.Response.AddHeader("<Debug>Cookie[" + s + "]", sTemp); // if (sName == "asp.net_sessionid") { // base.Response.AddHeader("<Debug>Cookie", sSubVals[1].Trim()); // gstrSessionID = sSubVals[1].Trim(); // } // } // } // } // } // } //base.Response.Write("\n"); //} if (gstrSessionID == "") { gstrSessionID = Guid.NewGuid().ToString().Replace("-", ""); } //base.Session.SessionID = SessionID; //base.Response.Cookies["ASP.NET_SessionId"].Value = gstrSessionID; //base.Response.AddHeader("<Debug>Cookie_New", gstrSessionID); //gstrConnectString = Pub.IO.ReadAllText(base.Server.MapPath(WebConfig.SZ_PATH_CONNECTSTRING)); //读取数据库连接设定 string szConnJson = dyk.IO.File.DisplacementUTF8.ReadAllText(Server.MapPath(WebConfig.SZ_FILE_CONNECTION), true); string szHost = ""; string szName = ""; string szPwd = ""; using (dyk.Format.XML json = new dyk.Format.XML(szConnJson)) { szHost = json["sqlserver.source"].InnerText; szName = json["sqlserver.user"].InnerText; szPwd = json["sqlserver.password"].InnerText; } //gszConnectString = Pub.IO.ReadAllText(base.Server.MapPath(WebConfig.SZ_PATH_CONNECTSTRING)); gszAosConnectString = "data source=" + szHost + ";user id=" + szName + ";Password="******";Initial Catalog=Aos"; //生成数据表连接 using (dyk.DB.Aos.AosAuthorize.ExecutionExp aa = new dyk.DB.Aos.AosAuthorize.ExecutionExp(gszAosConnectString)) { if (aa.GetDataByID(glngAuthorizeID)) { if (aa.Structure.DBIP != "") { gszBaseConnectString = "data source=" + aa.Structure.DBIP + ";user id=" + aa.Structure.DBUser + ";Password="******";Initial Catalog=Aos_" + aa.Structure.DBSign; gszDataConnectString = "data source=" + aa.Structure.DBIP + ";user id=" + aa.Structure.DBUser + ";Password="******";Initial Catalog=Aos_" + aa.Structure.DBSign + "_" + DateTime.Now.Year; gszUpdateConnectString = "data source=" + aa.Structure.DBIP + ";user id=" + aa.Structure.DBUser + ";Password="******";Initial Catalog=master"; } else { gszBaseConnectString = "data source=" + szHost + ";user id=" + szName + ";Password="******";Initial Catalog=Aos_" + aa.Structure.DBSign; gszDataConnectString = "data source=" + szHost + ";user id=" + szName + ";Password="******";Initial Catalog=Aos_" + aa.Structure.DBSign + "_" + DateTime.Now.Year; gszUpdateConnectString = "data source=" + szHost + ";user id=" + szName + ";Password="******";Initial Catalog=master"; } } } //建立本年份的分支数据库 string dbPath = ""; //读取数据库保存地址 string szFileSetting = Server.MapPath(WebConfig.SZ_FILE_SETTING); string szSetting = dyk.IO.File.UTF8.ReadAllText(szFileSetting, true); using (dyk.Format.XML xml = new dyk.Format.XML(szSetting)) { dbPath = xml["Database.SavePath"].InnerText; } //生成Aos库 using (dyk.Database.SQLClient Conn = new dyk.Database.SQLClient(gszUpdateConnectString)) { string szSql = "if not exists(select * from sysdatabases where name='Aos_Manage_" + DateTime.Now.Year + "')"; szSql += "create database [Aos_Manage_" + DateTime.Now.Year + "]"; szSql += "on primary ("; szSql += "name='Aos_Manage_" + DateTime.Now.Year + "_data',"; szSql += "filename='" + dbPath + "\\Aos_Manage_" + DateTime.Now.Year + ".mdf',"; szSql += "size=5mb,"; szSql += "filegrowth=15%)"; szSql += "log on ("; szSql += "name='Aos_Manage_" + DateTime.Now.Year + "_log',"; szSql += "filename='" + dbPath + "\\Aos_Manage_" + DateTime.Now.Year + "_log.ldf',"; szSql += "size=2mb,"; szSql += "filegrowth=1mb)"; Conn.ExecuteNonQuery(szSql); } gszIP = System.Web.HttpContext.Current.Request.UserHostAddress; gSession = new ClsSession(gszAosConnectString, gstrSessionID, glngAuthorizeID, gszIP); //gUsers = new Ly.DB.Dream.SystemUsers.ExecutionExp(gstrConnectString); gUser = new dyk.DB.Base.SystemUsers.ExecutionExp(gszBaseConnectString); gUser.GetDataByName(gSession.Manager); gConfig = new WebConfig(this); }
private void btnOk_Click(object sender, EventArgs e) { DataTableReader dr = null; bool IsOk = false; string sql = ""; string MacSysID = SysID; if (!CheckValue()) { return; } try { if (SysID == "") { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "1004", MacSN })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "1", MacSN, MacDoorType.ToString(), MacConnType, MacIPAddress, MacPort, MacConnPWD, MacDesc, SystemInfo.CardProtocol.ToString() }); db.ExecSQL(sql); dr.Close(); dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "1004", MacSN })); if (dr.Read()) { MacSysID = dr["MacSysID"].ToString(); IsOk = true; } } } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "1006", SysID, MacSN })); if (dr.Read()) { txtMacSN.Focus(); ShowErrorCannotRepeated(lblMacSN.Text); } else { sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "2", MacSN, MacDoorType.ToString(), MacConnType, MacIPAddress, MacPort, MacConnPWD, MacDesc, SystemInfo.CardProtocol.ToString(), SysID }); db.ExecSQL(sql); IsOk = true; } } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { db.WriteSYLog(this.Text, CurrentOprt, sql); //Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); frmMJMacInfoAddNext frm = new frmMJMacInfoAddNext(Title, CurrentOprt, MacSysID); frm.ShowDialog(); this.DialogResult = DialogResult.OK; this.Close(); } }
private void btnOk_Click(object sender, EventArgs e) { string RSortID = txtSortID.Text.Trim(); string RSortName = txtSortName.Text.Trim(); string RCalcID = cbbSort.SelectedIndex.ToString(); string RCalcName = cbbSort.Text.Trim(); string ROverID = (cbbOvertimeSort.SelectedIndex + 1).ToString(); string ROverName = cbbOvertimeSort.Text.Trim(); if (cbbOvertimeSort.SelectedIndex == -1) { ROverID = "NULL"; ROverName = ""; } string ROvertimeRate = txtOvertimeRate.Text.Trim(); double doubleNo; if (cbbSort.SelectedIndex == 1) { if (ROvertimeRate == "" || double.TryParse(ROvertimeRate, out doubleNo) == false || doubleNo <= 0) { ShowErrorEnterCorrect(label8.Text); return; } } else { ROvertimeRate = "NULL"; } string RStart = ""; string RTune = ""; string RInteger = ""; if (SystemInfo.AllowAdjust) { RStart = txtStart.Text.Trim(); RTune = txtTune.Text.Trim(); RInteger = txtInteger.Text.Trim(); int intNo = 0; if ((RStart != "" && !int.TryParse(RStart, out intNo)) || intNo < 0) { ShowErrorEnterCorrect(label4.Text); return; } if ((RTune != "" && !int.TryParse(RTune, out intNo)) || intNo < 0) { ShowErrorEnterCorrect(label5.Text); return; } if ((RInteger != "" && !int.TryParse(RInteger, out intNo)) || intNo < 0) { ShowErrorEnterCorrect(label6.Text); return; } } if (RStart == "") { RStart = "NULL"; } if (RTune == "") { RTune = "NULL"; } if (RInteger == "") { RInteger = "NULL"; } DataTableReader dr = null; bool IsOk = true; string sql = ""; try { if (IsAdd) { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000201, new string[] { "4", RSortID })); if (dr.Read()) { txtSortID.Focus(); ShowErrorCannotRepeated(label2.Text); IsOk = false; } dr.Close(); if (IsOk) { sql = Pub.GetSQL(DBCode.DB_000201, new string[] { "5", RSortID, RSortName, RCalcID, RCalcName, ROverID, ROverName, RStart, RTune, RInteger, "0", ROvertimeRate, "0", "0" }); } } else { sql = Pub.GetSQL(DBCode.DB_000201, new string[] { "6", RSortName, RCalcID, RCalcName, ROverID, ROverName, RStart, RTune, RInteger, "0", ROvertimeRate, "0", "0", SysID }); } if (IsOk) { SystemInfo.db.ExecSQL(sql); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E, sql); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { SystemInfo.db.WriteSYLog(this.Text, CurrentOprt, sql); //Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
private void LoadTextFormat() { DataTableReader dr = null; try { dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000001, new string[] { "15", KQTextFormatInfo.KQ_ConfigID, KQTextFormatInfo.KQ_TextFormat })); if (dr.Read()) { textFormat = new KQTextFormatInfo(dr["Value"].ToString()); } } catch (Exception E) { Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } chkAllow.Checked = textFormat.Allow; rbSepNo.Checked = textFormat.SepFlag == 0; rbSepTAB.Checked = textFormat.SepFlag == 1; rbSepCustom.Checked = textFormat.SepFlag == 2; if (!rbSepNo.Checked && rbSepTAB.Checked && rbSepCustom.Checked) { rbSepNo.Checked = true; } txtSep.Text = textFormat.SepStr; chkMacSN.Checked = textFormat.MacSNAllow; txtMacSN.Text = textFormat.MacSNLen.ToString(); txtMacSN.Tag = textFormat.MacSNOrder; chkEmpNo.Checked = textFormat.EmpNoAllow; txtEmpNo.Text = textFormat.EmpNoLen.ToString(); txtEmpNo.Tag = textFormat.EmpNoOrder; chkEmpName.Checked = textFormat.EmpNameAllow; txtEmpName.Text = textFormat.EmpNameLen.ToString(); txtEmpName.Tag = textFormat.EmpNameOrder; chkCardNo.Checked = textFormat.CardNoAllow; txtCardNo.Text = textFormat.CardNoLen.ToString(); txtCardNo.Tag = textFormat.CardNoOrder; chkDataTime.Checked = textFormat.DataTimeAllow; txtDataTime.Text = textFormat.DataTimeFormat; txtDataTime.Tag = textFormat.DataTimeOrder; chkOrder.Items.Clear(); if (textFormat.EmpNoOrder == 0) { chkOrder.Items.Add(chkEmpNo.Text); } else if (textFormat.EmpNameOrder == 0) { chkOrder.Items.Add(chkEmpName.Text); } else if (textFormat.CardNoOrder == 0) { chkOrder.Items.Add(chkCardNo.Text); } else if (textFormat.DataTimeOrder == 0) { chkOrder.Items.Add(chkDataTime.Text); } else { chkOrder.Items.Add(chkMacSN.Text); } if (textFormat.MacSNOrder == 1) { chkOrder.Items.Add(chkMacSN.Text); } else if (textFormat.EmpNoOrder == 1) { chkOrder.Items.Add(chkEmpNo.Text); } else if (textFormat.EmpNameOrder == 1) { chkOrder.Items.Add(chkEmpName.Text); } else if (textFormat.CardNoOrder == 1) { chkOrder.Items.Add(chkCardNo.Text); } else if (textFormat.DataTimeOrder == 1) { chkOrder.Items.Add(chkDataTime.Text); } if (textFormat.MacSNOrder == 2) { chkOrder.Items.Add(chkMacSN.Text); } else if (textFormat.EmpNoOrder == 2) { chkOrder.Items.Add(chkEmpNo.Text); } else if (textFormat.EmpNameOrder == 2) { chkOrder.Items.Add(chkEmpName.Text); } else if (textFormat.CardNoOrder == 2) { chkOrder.Items.Add(chkCardNo.Text); } else if (textFormat.DataTimeOrder == 2) { chkOrder.Items.Add(chkDataTime.Text); } if (textFormat.MacSNOrder == 3) { chkOrder.Items.Add(chkMacSN.Text); } else if (textFormat.EmpNoOrder == 3) { chkOrder.Items.Add(chkEmpNo.Text); } else if (textFormat.EmpNameOrder == 3) { chkOrder.Items.Add(chkEmpName.Text); } else if (textFormat.CardNoOrder == 3) { chkOrder.Items.Add(chkCardNo.Text); } else if (textFormat.DataTimeOrder == 3) { chkOrder.Items.Add(chkDataTime.Text); } if (textFormat.MacSNOrder == 4) { chkOrder.Items.Add(chkMacSN.Text); } else if (textFormat.EmpNoOrder == 4) { chkOrder.Items.Add(chkEmpNo.Text); } else if (textFormat.EmpNameOrder == 4) { chkOrder.Items.Add(chkEmpName.Text); } else if (textFormat.CardNoOrder == 4) { chkOrder.Items.Add(chkCardNo.Text); } else if (textFormat.DataTimeOrder == 4) { chkOrder.Items.Add(chkDataTime.Text); } }
private void btnOk_Click(object sender, EventArgs e) { string name = txtName.Text.Trim(); if (name == "") { txtName.Focus(); ShowErrorEnterCorrect(label1.Text); return; } if (!Pub.CheckTextMaxLength(label1.Text, name, txtName.MaxLength)) { txtName.Focus(); return; } if (picMap.Image == null) { Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error001", "")); return; } DataTableReader dr = null; bool IsOk = true; List <string> sql = new List <string>(); try { if (!db.IsOpen) { db.Open(SystemInfo.ConnStr); } if (IsAdd) { if (!db.GetServerGUID(ref SysID)) { return; } dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003007, new string[] { "2", name })); if (dr.Read()) { txtName.Focus(); ShowErrorCannotRepeated(label1.Text); IsOk = false; } sql.Add(Pub.GetSQL(DBCode.DB_003007, new string[] { "4", SysID, name })); } else { dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003007, new string[] { "3", SysID, name })); if (dr.Read()) { txtName.Focus(); ShowErrorCannotRepeated(label1.Text); IsOk = false; } sql.Add(Pub.GetSQL(DBCode.DB_003007, new string[] { "5", SysID, name })); } if (IsOk) { sql.Add(Pub.GetSQL(DBCode.DB_003007, new string[] { "9", SysID })); for (int j = 0; j < picMap.Controls.Count; j++) { doorInfo = (TMapDoorInfo)picMap.Controls[j].Tag; sql.Add(Pub.GetSQL(DBCode.DB_003007, new string[] { "10", SysID, doorInfo.DoorSysID, picMap.Controls[j].Location.X.ToString(), picMap.Controls[j].Location.Y.ToString() })); } if (db.ExecSQL(sql) != 0) { IsOk = false; } } if (IsOk) { byte[] buff = new byte[0]; MemoryStream ms = new MemoryStream(); Bitmap t = new Bitmap(picMap.Image); t.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); buff = ms.ToArray(); db.UpdateByteData(Pub.GetSQL(DBCode.DB_003007, new string[] { "6", SysID }), "mapPic", buff); } } catch (Exception E) { IsOk = false; Pub.ShowErrorMsg(E); } finally { if (dr != null) { dr.Close(); } dr = null; } if (IsOk) { db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } }
private void btnOk_Click(object sender, EventArgs e) { string T0 = txtTitle0.Text; string T1 = txtTitle1.Text; string T2 = txtTitle2.Text; string T3 = txtTitle3.Text; string T4 = txtTitle4.Text; int I0 = cbbOption0.SelectedIndex; int I1 = cbbOption1.SelectedIndex; int I2 = cbbOption2.SelectedIndex; int I3 = cbbOption3.SelectedIndex; int I4 = cbbOption4.SelectedIndex; if (!Pub.CheckTextMaxLength(label1.Text, T0, txtTitle0.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label2.Text, T1, txtTitle1.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label3.Text, T2, txtTitle2.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label4.Text, T3, txtTitle3.MaxLength)) { return; } if (!Pub.CheckTextMaxLength(label5.Text, T4, txtTitle4.MaxLength)) { return; } int PrintLine = 0; int.TryParse(txtLine.Text.Trim(), out PrintLine); if ((PrintLine < 0) || (PrintLine > 255)) { string msg = string.Format(Pub.GetResText(formCode, "Error001", ""), 0, 255); Pub.ShowErrorMsg(msg); return; } string printStr = T0 + "@" + T1 + "@" + T2 + "@" + T3 + "@" + T4 + "@" + I0.ToString() + "@" + I1.ToString() + "@" + I2.ToString() + "@" + I3.ToString() + "@" + I4.ToString() + "@" + PrintLine.ToString(); string sql = Pub.GetSQL(DBCode.DB_004004, new string[] { "120", printStr, SysID }); try { db.ExecSQL(sql); byte[] buff = new byte[0]; if (picLogo.BackgroundImage != null) { MemoryStream ms = new MemoryStream(); picLogo.BackgroundImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); buff = ms.ToArray(); } db.UpdateByteData(Pub.GetSQL(DBCode.DB_004004, new string[] { "122", SysID }), "PrintLogo", buff); } catch (Exception E) { Pub.ShowErrorMsg(E, sql); return; } db.WriteSYLog(this.Text, CurrentOprt, sql); Pub.MessageBoxShow(Pub.GetResText(formCode, "MsgSaveSucceed", ""), MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); }