private void AddRoster() { string[] firstName = { "赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈" }; string[] lastName = { "尹", "沛", "雯", "梅", "寒", "凝", "典", "秋", "蝶", "慧" }; ArrayList rosterList = new ArrayList(); Random ra = new Random(); for (int x = 0; x < 10; ++x) { for (int y = 0; y < 10; ++y) { RosterInfo roster = new RosterInfo(); roster.Name = "" + firstName.GetValue(x) + lastName.GetValue(y); if (y % 2 == 0) { roster.Sex = true; } else { roster.Sex = false; } roster.IdentityNo = "" + ra.Next(1, 10); for (int z = 1; z < 18; ++z) { roster.IdentityNo += ra.Next(10); } rosterList.Add(roster); } } rosterService.AddRosterData(rosterList); }
private bool checkAdd() { string msg = ""; bool isEmpty = false; int count = 0; string[] condReqName = { "txtMobile", "txtPhone1", "txtPhone2" }; //判斷欄位三個至少填一個 string[] condName = { "txtName", "txtAddr", "txtMain" }; //必填欄位 foreach (Control c in this.Controls) { if (c is BunifuMetroTextbox) { BunifuMetroTextbox textBox = c as BunifuMetroTextbox; if (condName.Contains(textBox.Name) && textBox.Text == string.Empty) { msg = "欄位不能為空值!"; isEmpty = true; } else if (condReqName.Contains(textBox.Name) && textBox.Text == string.Empty) { count++; } } else if (c is BunifuDropdown) { BunifuDropdown dropdown = c as BunifuDropdown; if (dropdown.selectedIndex == -1) { msg = "欄位不能為空值!"; isEmpty = true; } } } if (count == condReqName.Length) { msg = "電話欄位至少輸入一欄!"; isEmpty = true; } if (!isEmpty && mode == mode.Add) { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text); if (vRoster.calculateCount() > 0) { msg = "該手機號碼已經有資料!請重複確認!"; } } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg)? true: false); }
public Roster(RosterInfo rosterInfo) { RoleSlots = rosterInfo.RoleSlotInfos.Select(rsi => CreateRoleSlot(rsi)).ToList(); RoleSlots.Add(CreateTempRTSlot()); RoleSlots.Add(CreateTempRTSlot()); RoleSlots.Add(CreateTempRTSlot()); RoleSlots.Add(CreateTempRTSlot()); RoleSlots.Add(CreateTempRTSlot()); }
public TradeEdit(mode pmode, string pserno = "", RosterInfo pRosterInfo = null) { InitializeComponent(); APConfig.loadPhrase(ddlDealer, PhraseCategory.案件負責人.ToString()); APConfig.loadPhrase(ddlType, PhraseCategory.收入類別.ToString()); serno = pserno; mode = pmode; mRosterInfo = pRosterInfo; initView(); }
public void AddRosterInfo(RosterInfo rosterInfo) { string connStr = SqlHelper.GetConnString(); string sqlText = "INSERT INTO Roster (name, sex, identityNo, type, department) VALUES (@Name, @Sex, @IdentityNo, @Type, @Department)"; SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@Name", rosterInfo.Name), new SqlParameter("@Sex", rosterInfo.Sex), new SqlParameter("@IdentityNo", rosterInfo.IdentityNo), new SqlParameter("@Type", rosterInfo.Type), new SqlParameter("@Department", rosterInfo.Department) }; SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, sqlText, sqlParas); }
private void submit() { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text); if (!vRoster.load()) { APConfig.SweetAlert(ShowBoxType.alert, "查無此主要號碼"); } else { this.Hide(); TradeEdit form = new TradeEdit(mode.Add, "", vRoster); form.ShowDialog(); this.Close(); } }
private void OnRosterItem(object sender, RosterItem item) { var vsId = XmppIdConverter.Convert(item.Jid); if (_container.Contains(vsId) && item.Subscription == SubscriptionType.remove) { _listener.RemoveInterlocutor(vsId); } else if (_container.Contains(vsId) && item.Subscription != SubscriptionType.remove) { _listener.UpdateInterlocutor(RosterInfo.Create(item)); } else if (!_container.Contains(vsId) && item.Subscription != SubscriptionType.remove) { _listener.CreateInterlocutor(RosterInfo.Create(item)); } }
public ArrayList GetRosterInfoByExamType(string examType) { string connStr = SqlHelper.GetConnString(); string sqlText = "SELECT * FROM Roster WHERE examType = @ExamType"; SqlParameter[] sqlParas = new SqlParameter[1]; sqlParas[0] = new SqlParameter("@ExamType", examType); ArrayList idRowList = SqlHelper.ExecuteArrayList(connStr, CommandType.Text, sqlText, sqlParas); ArrayList idList = new ArrayList(); foreach (DataRow r in idRowList) { RosterInfo rosterInfo = new RosterInfo(); rosterInfo.Id = (int)r["id"]; rosterInfo.IdentityNo = r["identityNo"].ToString(); rosterInfo.Name = r["name"].ToString(); rosterInfo.Type = r["examType"].ToString(); rosterInfo.Department = r["department"].ToString(); rosterInfo.Sex = bool.Parse(r["sex"].ToString()); idList.Add(rosterInfo); } return(idList); }
private void txtMain_Leave(object sender, EventArgs e) { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text); if (txtMain.Text.Length > 10) { APConfig.SweetAlert(ShowBoxType.alert, "此主要號碼不符合(市話/手機)格式!"); txtMain.Text = ""; txtMain.Focus(); } else if (vRoster.calculateCount() > 0) { APConfig.SweetAlert(ShowBoxType.alert, "此主要號碼已經被使用!"); txtMain.Text = ""; txtMain.Focus(); } else { txtMobile.Text = txtMain.Text.Length == 10 ? txtMain.Text : ""; txtPhone1.Text = txtMain.Text.Length < 10 ? txtMain.Text : ""; } }
private bool checkAdd() { string msg = ""; int n, count = 0; string[] condReqName = { "txtMobile1", "txtMobile2", "txtPhone" }; //判斷欄位三個至少填一個 string[] condName = { "txtName", "txtNo" }; //必填欄位 string[] condNumberName = { "txtAmount" }; //判斷數字欄位 foreach (Control c in this.Controls) { if (c is BunifuMetroTextbox) { BunifuMetroTextbox textBox = c as BunifuMetroTextbox; if (condName.Contains(textBox.Name) && textBox.Text == string.Empty) { msg = "必要欄位不能為空值!"; } else if (condReqName.Contains(textBox.Name) && textBox.Text == string.Empty) { count++; } else if (condNumberName.Contains(textBox.Name) && textBox.Text != string.Empty) { if (!int.TryParse(textBox.Text, out n)) { msg = "金額欄位請輸入數字"; } } } else if (c is BunifuDropdown) { BunifuDropdown dropdown = c as BunifuDropdown; if (dropdown.selectedIndex == -1) { msg = "欄位不能為空值!"; } } } if (count == condReqName.Length) { msg = "電話欄位至少輸入一欄!"; } if (string.IsNullOrEmpty(msg) && mode == mode.Add) { foreach (DataGridViewRow row in dgvItem.Rows) { if (txtNo.Text == row.Cells["dgvItem_No"].Value.ToString()) { msg = "該訂單編號已經存在列表中!請重複確認!!"; break; } } } if (string.IsNullOrEmpty(msg) && mode == mode.Add) { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.no.ToString(), txtNo.Text); if (vRoster.calculateCount() > 0) { msg = "該訂單編號已經有資料!請重複確認!"; } } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg) ? true : false); }
private void initView() { if (mode == mode.Add) { btnOK.ButtonText = "新增"; btnOK.IdleFillColor = Color.FromArgb(33, 166, 117); btnOK.IdleLineColor = Color.FromArgb(33, 166, 117); btnOK.ActiveFillColor = Color.FromArgb(33, 166, 117); btnOK.ActiveLineColor = Color.FromArgb(33, 166, 117); dpkOrderDTTM.Value = DateTime.Today; } else if (mode == mode.Edit) { btnOK.ButtonText = "修改"; btnOK.IdleFillColor = Color.FromArgb(255, 161, 0); btnOK.IdleLineColor = Color.FromArgb(255, 161, 0); btnOK.ActiveFillColor = Color.FromArgb(255, 161, 0); btnOK.ActiveLineColor = Color.FromArgb(255, 161, 0); btnItemAdd.Visible = false; btnItemDel.Visible = false; btnClear.Visible = false; lblTotalCount.Visible = false; btnGetAddress.Visible = false; RosterInfo view = new RosterInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(RosterInfo.ncConditions.serno.ToString(), serno); view.load(); if (view.load()) { txtNo.Text = view.RST_NO; txtName.Text = view.RST_NAME; txtPhone.Text = view.RST_PHONE; txtMobile1.Text = view.RST_MOBILE1; txtMobile2.Text = view.RST_MOBILE2; txtAmount.Text = view.RST_AMOUNT.ToString(); txtAddr.Text = view.RST_ADDR; txtComment1.Text = view.RST_COMMENT1; txtComment2.Text = view.RST_COMMENT2; txtComment3.Text = view.RST_COMMENT3; dpkOrderDTTM.Value = view.RST_ORDERDTTM; } } else if (mode == mode.View) { DisableControls(); btnOK.ButtonText = "確認"; btnItemAdd.Visible = false; btnItemDel.Visible = false; btnClear.Visible = false; lblTotalCount.Visible = false; btnGetAddress.Visible = false; RosterInfo view = new RosterInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(RosterInfo.ncConditions.serno.ToString(), serno); view.load(); if (view.load()) { txtNo.Text = view.RST_NO; txtName.Text = view.RST_NAME; txtPhone.Text = view.RST_PHONE; txtMobile1.Text = view.RST_MOBILE1; txtMobile2.Text = view.RST_MOBILE2; txtAmount.Text = view.RST_AMOUNT.ToString(); txtAddr.Text = view.RST_ADDR; txtComment1.Text = view.RST_COMMENT1; txtComment2.Text = view.RST_COMMENT2; txtComment3.Text = view.RST_COMMENT3; dpkOrderDTTM.Value = view.RST_ORDERDTTM; } } }
private void memberLoadData(int pageNum) { int total = 0; dgvMember.Rows.Clear(); DataGridViewRowCollection rows = dgvMember.Rows; RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = " 1=1 "; if (!string.IsNullOrEmpty(txtMemberName.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.name.ToString(), txtMemberName.Text); } if (!string.IsNullOrEmpty(txtMemberTel.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.phoneLike.ToString(), txtMemberTel.Text); } if (!string.IsNullOrEmpty(txtMemberAddr.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.address.ToString(), txtMemberAddr.Text); } if (!string.IsNullOrEmpty(txtMemberNo.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.noLike.ToString(), txtMemberNo.Text); } if (!string.IsNullOrEmpty(dpkMemberOrderSDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderSDTTM.ToString(), dpkMemberOrderSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkMemberOrderEDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderEDTTM.ToString(), dpkMemberOrderEDTTM.Value.ToString("yyyy/MM/dd")); } //組排序指令 if (dgvMember.SortedColumn == null) { vRoster.OrderBy = vRoster.getOptionOrderBy(RosterInfo.ncSort.Default.ToString()); } else { string sortname = dgvMember.SortedColumn.Name; string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvMember.SortOrder.ToString()).ToString(); vRoster.OrderBy = string.Format("{0} {1}", vRoster.getOptionOrderBy(sortname), sortmode); } //查詢頁數初始化且自動跳轉至第一頁 if (pageNum == 0) { APConfig.loadPage(ddlMemberPage, vRoster.calculatePage(APConfig.PageCount)); return; } //塞入資料 lblMemberTotal.Text = vRoster.calculateCount().ToString(); DataSet ds = APConfig.GoPage(vRoster.SQLStatement, pageNum); foreach (DataRow dr in ds.Tables[0].Rows) { rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[3], dr.ItemArray[6], dr.ItemArray[10], dr.ItemArray[11], dr.ItemArray[12] }); } //計算總金額 vRoster.load(); while (!vRoster.IsEof) { total += vRoster.RST_AMOUNT; vRoster.next(); } lblMemberAMTTotal.Text = string.Format("{0} 元", total.ToString()); }
private void initView() { if (mode == mode.Add) { btnOK.ButtonText = "新增"; btnOK.IdleFillColor = Color.FromArgb(33, 166, 117); btnOK.IdleLineColor = Color.FromArgb(33, 166, 117); btnOK.ActiveFillColor = Color.FromArgb(33, 166, 117); btnOK.ActiveLineColor = Color.FromArgb(33, 166, 117); panelInfo.Visible = false; ddlPrinciple.SelectedIndex = 0; ddlSex.SelectedIndex = 0; } else if (mode == mode.Edit) { btnOK.ButtonText = "修改"; btnOK.IdleFillColor = Color.FromArgb(255, 161, 0); btnOK.IdleLineColor = Color.FromArgb(255, 161, 0); btnOK.ActiveFillColor = Color.FromArgb(255, 161, 0); btnOK.ActiveLineColor = Color.FromArgb(255, 161, 0); txtMain.Enabled = false; panelInfo.Visible = true; RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = " 1=1 "; vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.serno.ToString(), serno); if (vRoster.load()) { txtName.Text = vRoster.RST_NAME; txtMain.Text = vRoster.RST_MAIN; txtPhone1.Text = vRoster.RST_PHONE1; txtPhone2.Text = vRoster.RST_PHONE2; txtMobile.Text = vRoster.RST_MOBILE; txtFax.Text = vRoster.RST_FAX; txtAddr.Text = vRoster.RST_ADDR; txtComment.Text = vRoster.RST_COMMENT; ddlSex.SelectedIndex = APConfig.getSelectIndex(ddlSex, vRoster.RST_SEX); ddlPrinciple.SelectedIndex = APConfig.getSelectIndex(ddlPrinciple, vRoster.RST_PRINCIPAL); lblInsertBy.Text = vRoster.RST_INSERTBY; lblInsertDTTM.Text = vRoster.RST_INSERTDTTM.ToString(); lblModifyBy.Text = vRoster.RST_MODIFIEDBY; lblModifyDTTM.Text = vRoster.RST_MODIFIEDDTTM.ToString(); } } else if (mode == mode.View) { DisableControls(); btnOK.ButtonText = "確認"; txtMobile.Enabled = false; btnGetAddress.Visible = false; panelInfo.Visible = true; RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = " 1=1 "; vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.serno.ToString(), serno); vRoster.load(); txtName.Text = vRoster.RST_NAME; txtMain.Text = vRoster.RST_MAIN; txtPhone1.Text = vRoster.RST_PHONE1; txtPhone2.Text = vRoster.RST_PHONE2; txtMobile.Text = vRoster.RST_MOBILE; txtFax.Text = vRoster.RST_FAX; txtAddr.Text = vRoster.RST_ADDR; txtComment.Text = vRoster.RST_COMMENT; ddlSex.SelectedIndex = APConfig.getSelectIndex(ddlSex, vRoster.RST_SEX); ddlPrinciple.SelectedIndex = APConfig.getSelectIndex(ddlPrinciple, vRoster.RST_PRINCIPAL); lblInsertBy.Text = vRoster.RST_INSERTBY; lblInsertDTTM.Text = vRoster.RST_INSERTDTTM.ToString(); lblModifyBy.Text = vRoster.RST_MODIFIEDBY; lblModifyDTTM.Text = vRoster.RST_MODIFIEDDTTM.ToString(); } }
private void btnOK_Click(object sender, EventArgs e) { if (mode == mode.Add && checkAdd()) { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.main.ToString(), txtMain.Text); if (vRoster.calculateCount() == 0) { Roster entRoster = new Roster(APConfig.Conn); entRoster.RST_SERNO = My.GenSerNo(); entRoster.RST_NAME = txtName.Text; entRoster.RST_MAIN = txtMain.Text; entRoster.RST_SEX = ddlSex.SelectedItem.ToString(); entRoster.RST_PHONE1 = txtPhone1.Text; entRoster.RST_PHONE2 = txtPhone2.Text; entRoster.RST_MOBILE = txtMobile.Text; entRoster.RST_FAX = txtFax.Text; entRoster.RST_ADDR = txtAddr.Text; entRoster.RST_PRINCIPAL = ddlPrinciple.SelectedItem.ToString(); entRoster.RST_COMMENT = txtComment.Text; entRoster.RST_MODIFIEDBY = APConfig.AccountName; entRoster.RST_MODIFIEDDTTM = DateTime.Now; entRoster.RST_INSERTBY = APConfig.AccountName; entRoster.RST_INSERTDTTM = DateTime.Now; entRoster.insert(); APConfig.SweetAlert(ShowBoxType.alert, "新增完成"); this.DialogResult = DialogResult.OK; this.Close(); } else { APConfig.SweetAlert(ShowBoxType.alert, "主要號碼已經存在"); txtMain.Focus(); } } else if (mode == mode.Edit && checkAdd()) { Roster entRoster = new Roster(APConfig.Conn); entRoster.RST_SERNO = serno; entRoster.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10}" , Roster.ncFields.RST_NAME.ToString() , Roster.ncFields.RST_MAIN.ToString() , Roster.ncFields.RST_SEX.ToString() , Roster.ncFields.RST_PHONE1.ToString() , Roster.ncFields.RST_PHONE2.ToString() , Roster.ncFields.RST_FAX.ToString() , Roster.ncFields.RST_ADDR.ToString() , Roster.ncFields.RST_PRINCIPAL.ToString() , Roster.ncFields.RST_COMMENT.ToString() , Roster.ncFields.RST_MODIFIEDBY.ToString() , Roster.ncFields.RST_MODIFIEDDTTM.ToString()); entRoster.RST_NAME = txtName.Text; entRoster.RST_MAIN = txtMain.Text; entRoster.RST_SEX = ddlSex.SelectedItem.ToString(); entRoster.RST_PHONE1 = txtPhone1.Text; entRoster.RST_PHONE2 = txtPhone2.Text; entRoster.RST_FAX = txtFax.Text; entRoster.RST_ADDR = txtAddr.Text; entRoster.RST_PRINCIPAL = ddlPrinciple.SelectedItem.ToString(); entRoster.RST_COMMENT = txtComment.Text; entRoster.RST_MODIFIEDBY = APConfig.AccountName; entRoster.RST_MODIFIEDDTTM = DateTime.Now; entRoster.update(); APConfig.SweetAlert(ShowBoxType.alert, "修改完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.View) { this.DialogResult = DialogResult.OK; this.Close(); } else { return; } }