protected void Button1_Click(object sender, EventArgs e) { if (Session["CustomerUID"] != null && (dsPackage.dtSelectedPackageDataTable)Session["selectedPackage"] != null) { OrderPackageDetail opd; OrderPackage op = new OrderPackage(); clsPackage pk = new clsPackage(); DataTable dt = new DataTable(); DataTable dtOrderPackage = new DataTable(); int OrderPackageUID = 0; //Insert Order op.CustomerUID = Convert.ToInt32(Session["CustomerUID"]); op.OrderNo = lblOrderNo.Text.Trim(); op.OrderDate = Convert.ToDateTime(lblOrderDate.Text.Trim()); op.Total = Convert.ToDecimal(txtTotal.Text.Trim()); op.VAT = Convert.ToDecimal(txtVat.Text.Trim()); op.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); op.StatusFlage = "A"; op.CUser = 99; op.CWhen = DateTime.Now; op.MUser = 99; op.MWhen = DateTime.Now; db.OrderPackages.InsertOnSubmit(op); db.SubmitChanges(); //Insert Order Detail dtOrderPackage = pk.SearchPackageOrdeByOrderNo(lblOrderNo.Text.Trim()); if (dtOrderPackage.Rows.Count > 0 && dtOrderPackage != null) { OrderPackageUID = Convert.ToInt32(dtOrderPackage.Rows[0]["UID"]); dt = (dsPackage.dtSelectedPackageDataTable)Session["selectedPackage"]; for (int i = 0; i <= dt.Rows.Count - 1; i++) { opd = new OrderPackageDetail(); opd.OrderPackageUID = OrderPackageUID; opd.PackageUID = Convert.ToInt32(dt.Rows[i]["UID"]); opd.UnitPrice = Convert.ToDecimal(dt.Rows[i]["UnitPrice"]); opd.Qty = Convert.ToInt32(dt.Rows[i]["Qty"]); opd.Total = opd.UnitPrice * opd.Qty; opd.StatusFlag = "A"; opd.CUser = 99; opd.CWhen = DateTime.Now; opd.MUser = 99; opd.MWhen = DateTime.Now; db.OrderPackageDetails.InsertOnSubmit(opd); db.SubmitChanges(); opd = null; } } Session["OrderNo"] = lblOrderNo.Text.Trim(); Response.Redirect("PackageOrder3.aspx"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('Session หมดอายุ กรุณาเลือกแพ็คเกจที่ต้องการใหม่อีกครั้งครับ')", true); } }
private void button1_Click(object sender, EventArgs e) { context.box.InsertOnSubmit(new box { box_genre = genre }); try { context.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } list_genre_SelectedIndexChanged(sender, null); comboBox1.SelectedIndex = comboBox1.Items.Count - 1; }
protected void gvNews_RowCommand(object sender, GridViewCommandEventArgs e) { int UID = Convert.ToInt32(e.CommandArgument); //ถ้ากดปุ่ม Delete if (e.CommandName == "DeleteNews") { var tbNews = from n in db.News where n.UID == UID select n; foreach (New n in tbNews) { db.News.DeleteOnSubmit(n); } try { db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindNews(); } //ถ้ากดปุ่ม Edit else if (e.CommandName == "EditNews") { ucColorBox1.IFrame("NewsForm.aspx?UID=" + UID + "", "90%", "90%", false); } }
protected void gvEvent_RowCommand(object sender, GridViewCommandEventArgs e) { int UID = Convert.ToInt32(e.CommandArgument); //ถ้ากดปุ่ม Delete if (e.CommandName == "DeleteEvent") { try { var tbEvent = from ev in db.Events where ev.UID == UID select ev; foreach (Event evt in tbEvent) { db.Events.DeleteOnSubmit(evt); } db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindEvent(); } //ถ้ากดปุ่ม Edit else if (e.CommandName == "EditEvent") { ucColorBox1.IFrame("EventForm.aspx?UID=" + UID + "", "90%", "90%", true); } }
private void button_refresh_Click(object sender, EventArgs e) { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); var rows = itemsGridView1.SelectedRows; if (itemsGridView1.SelectedRows.Count > 0) { for (int i = 0; i < rows.Count; i++) { int id = int.Parse(rows[i].Cells[0].Value.ToString()); var list = from n in context.item where n.item_id == id select n; foreach (var item in list) { item.item_tag_printed = false; } } try { context.SubmitChanges(); MessageBox.Show("再印刷登録しました"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("登録する行を選択してください"); } }
private void SellForm_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.Z) { var context = new DBClassDataContext(Globals.ConnectionString); if (this.privItem_id == 0) { return; } item privItem = context.item.Single(n => n.item_id == privItem_id); int? priv_canceledsellprice = privItem.item_sellprice; privItem.item_sellprice = privItemSellPrice; privItem.item_selltime = privItemSellTime; privItem.item_sell_operator = privItemSellOperatorId; context.SubmitChanges(); this.setItem(privItem); this.textBox_baika.Text = priv_canceledsellprice.ToString(); this.textBox_baika.Focus(); this.textBox_baika.SelectAll(); this.privItem_id = 0; } }
private void PrintSelections() { var rows = this.dataGridView1.SelectedRows; List <int> items = new List <int>(); if (rows.Count == 0) { return; } DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); for (int i = 0; i < rows.Count; i++) { var list = from n in context.item where n.item_receipt_id == int.Parse(rows[i].Cells[0].Value.ToString().Substring(1, 4)) select n; foreach (var item in list) { items.Add(item.item_id); } } ItemsPrintDocument.PrintItems(items); context.SubmitChanges(); }
private void button_mibai_Click(object sender, EventArgs e) { if (curItem_id == 0) { return; } if (curItem_id < 90000) { var context = new DBClassDataContext(Globals.ConnectionString); var curItem = context.item.Single(n => n.item_id == curItem_id); curItem.item_sellprice = null; curItem.item_selltime = null; context.SubmitChanges(); this.DoKansaItem(curItem_id); this.label_error.Text = "商品を未売却にしました"; } else { var context = new DBClassDataContext(Globals.ConnectionString); var curItem = (from n in context.item where n.item_box_id == (curItem_id - 90000) select n).ToList(); foreach (var q in curItem) { q.item_sellprice = null; q.item_selltime = null; } context.SubmitChanges(); this.DoKansaItem(curItem_id); this.label_error.Text = "商品を未売却にしました"; } }
//protected void btAdmin_Click(object sender, EventArgs e) //{ // ucColorBox1.IFrame("PromotionForm.aspx", "90%", "90%", true); //} protected void gvPromotion_RowCommand(object sender, GridViewCommandEventArgs e) { int UID = Convert.ToInt32(e.CommandArgument); //ถ้ากดปุ่ม Delete if (e.CommandName == "DeletePromotion") { var tbpromotion = from p in db.Promotions where p.UID == UID select p; foreach (Promotion p in tbpromotion) { //db.Promotions.DeleteOnSubmit(p); } try { db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindPromotion(); } //ถ้ากดปุ่ม Edit else if (e.CommandName == "EditPromotion") { ucColorBox1.IFrame("PromotionForm.aspx?UID=" + UID + "", "90%", "90%", true); } }
private void button_restore_Click(object sender, EventArgs e) { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); var list = from n in context.item orderby n.item_id ascending select n; foreach (var printeditem_id in pPrint) { foreach (var item in list) { if (item.item_id == printeditem_id) { item.item_tag_printed = false; } } } try { context.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_mibai_Click(object sender, EventArgs e) { if (curItem_id == 0) { return; } privItem_id = curItem_id; var context = new DBClassDataContext(Globals.ConnectionString); if (curItem_id < 90000) { item curItem = context.item.Single(n => n.item_id == curItem_id); privItemSellPrice = curItem.item_sellprice; privItemSellTime = curItem.item_selltime; privItemSellOperatorId = curItem.item_sell_operator; curItem.item_sellprice = null; curItem.item_selltime = null; } else { box curBox = context.box.Single(n => n.box_id == (curItem_id - 90000)); var curItems = (from n in context.item where n.item_box_id == curBox.box_id select n).ToList(); foreach (var q in curItems) { q.item_sellprice = null; q.item_selltime = null; } } context.SubmitChanges(); this.textBox_ban_err("次の品番を入力してね"); }
private void button_delete_Click(object sender, EventArgs e) { if (Box_list.SelectedIndex >= 0) { try { var item = (from n in context.box where n.box_id == (int)Box_list.SelectedItem select n).First(); context.box.DeleteOnSubmit(item); Box_list.Items.RemoveAt(Box_list.SelectedIndex); context.SubmitChanges(); } catch { } } }
private void BindArticle() { clsDefault clsDefault = new clsDefault(); int UID = Convert.ToInt32(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { try { var tbArticle = from a in db.Articles where a.UID == UID select a; foreach (Article a in tbArticle) { lblUID.Text = a.UID.ToString(); lblSubject.Text = a.Subject; lblDetail.Text = a.Detail; PicFull.ImageUrl = a.PicFull; lblSiteMap.Text = a.Subject; Page.MetaKeywords = a.MetaKeywords; Page.MetaDescription = a.MetaDescription; //Update View Article a.NumberView = a.NumberView + 1; NumberView.Text = a.NumberView.ToString() + " View"; NumberLike.Text = a.NumberLike.ToString(); NumberDisLike.Text = a.NumberDislike.ToString(); } db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } } else { Response.Redirect("ArticleView.aspx"); } }
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string value; if (this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null) { return; } else { value = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); } DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); int id; @operator operator_item; if (int.TryParse((this.dataGridView1.Rows[e.RowIndex].Cells["OperatorId"].Value ?? "").ToString(), out id)) { operator_item = [email protected](n => n.operator_id == id); } else { operator_item = new @operator(); [email protected](operator_item); } switch (e.ColumnIndex) { case 1: operator_item.operator_name = value; break; case 2: operator_item.operator_comment = value; break; } try { context.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } LoadOperator(); }
private void button_reset_Click(object sender, EventArgs e) { var context = new DBClassDataContext(Globals.ConnectionString); DialogResult res = MessageBox.Show("このコマンドでは、「監査対象」の商品を全て未監査に戻します。\n" + "よろしいですか?", "監査やりなおし?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (res != DialogResult.Yes) { return; } List <item> lit = (from n in context.item where n.item_kansa_end == null && n.item_sellprice != null select n).ToList(); DateTime dt = DateTime.Now; for (int i = 0; i < lit.Count; i++) { lit[i].item_kansa_flag1 = null; } while (true) { try { context.SubmitChanges(); break; } catch { if (Globals.ConnectionString.State == ConnectionState.Open) { } else { this.label_error.Text = "監査に失敗しました。"; return; } } } this.RefreshRemain(); }
private void Edit() { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); try { var data = (from n in context.genre where n.genre_name == listBox_genre.SelectedItem.ToString() select n).First(); data.genre_name = textBox1.Text; context.SubmitChanges(); textBox1.Text = ""; listBox_genre.ClearSelected(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_save_Click(object sender, EventArgs e) { var context = new DBClassDataContext(Globals.ConnectionString); var box = context.box.Single(n => n.box_id == boxid); box.box_comment = text_name.Text; //削除 foreach (int itemid in eraselist) { var q = context.item.Single(n => n.item_id == itemid); if (q.item_box_id == boxid) { q.item_box_id = null; q.item_sellprice_bag = null; } } //追加 foreach (DataGridViewRow row in dataGridView1.Rows) { int sellprice; if (int.TryParse((row.Cells["ItemSellPrice"].Value ?? "").ToString(), out sellprice)) { var item = context.item.Single(n => n.item_id == (int)row.Cells["ItemId"].Value); item.item_box_id = boxid; item.item_sellprice_bag = sellprice; row.ErrorText = null; } else { MessageBox.Show("不正な文字列です"); row.ErrorText = "不正な文字列です"; return; } } context.SubmitChanges(); MessageBox.Show("保存しました"); button_item.Enabled = false; button_save.Enabled = false; label_Price.Text = ""; dataGridView1.Rows.Clear(); RefreshData(); }
protected void btDelete_Click(object sender, EventArgs e) { var tbEvent = from ev in db.Events where ev.UID == Convert.ToInt32(lblUID.Text) select ev; foreach (Event evt in tbEvent) { db.Events.DeleteOnSubmit(evt); } try { db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindEvent(); }
protected void btDelete_Click(object sender, EventArgs e) { var tbNews = from n in db.News where n.UID == Convert.ToInt32(lblUID.Text) select n; foreach (New n in tbNews) { db.News.DeleteOnSubmit(n); } try { db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindNews(); }
private void button_bagadd_Click(object sender, EventArgs e) { if (text_name.Text.Length > 0) { var context = new DBClassDataContext(Globals.ConnectionString); var newbox = new box { box_isbag = true, box_genre = genreid, box_comment = text_name.Text }; context.box.InsertOnSubmit(newbox); boxid = newbox.box_id; context.SubmitChanges(); dataGridView1.Rows.Clear(); RefreshData(); comboBox_bag.SelectedIndex = comboBox_bag.Items.Count - 1; LoadData(); } }
protected void btDelete_Click(object sender, EventArgs e) { var tbPromotion = from p in db.Promotions where p.UID == Convert.ToInt32(lblUID.Text) select p; foreach (Promotion p in tbPromotion) { db.Promotions.DeleteOnSubmit(p); } try { db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } BindPromotion(); }
private void InsertCustomer() { try { if (VerifyIDCard(IDCard)) { Customer cus = new Customer(); cus.Name = txtName.Text.Trim(); cus.Surname = txtSurname.Text.Trim(); cus.SEX = rdbMale.Checked == true ? "M" : "F"; cus.IDCard = txtIDCardNo.Text.Trim(); cus.Address = txtAddress.Text.Trim(); cus.District = txtDistrict.Text.Trim(); cus.Prefecture = txtPrefecture.Text.Trim(); cus.Province = txtProvince.Text.Trim(); cus.Zipcode = txtZipcode.Text.Trim(); cus.Email = txtEmail.Text.Trim(); cus.Tel = txtTel.Text.Trim(); cus.Detail = txtDetail.Text.Trim(); cus.CUser = 1; cus.CWhen = DateTime.Now; cus.MUser = 1; cus.MWhen = DateTime.Now; cus.StatusFlag = "A"; db.Customers.InsertOnSubmit(cus); db.SubmitChanges(); Session["CustomerUID"] = cus.UID; Response.Redirect("PackageOrder2.aspx"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('กรุณากรอกหมายเลขบัตรประชาชนให้ถูกต้องด้วยครับ')", true); } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } }
private void ReceiptForm_KeyDown(object sender, KeyEventArgs e) { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); if (receipt_id > 0) { var receipt_data = (from n in context.receipt where n.receipt_id == receipt_id select n).First(); string curcom = receipt_data.receipt_comment; //コメント入力 if (e.Alt && e.Control && e.KeyCode == Keys.C) { string comment; if (DialogResult.OK == InputBox.Show_Dialog("コメントを入力してください", "コメント入力", curcom, out comment, ImeMode.On, HorizontalAlignment.Left)) { receipt_data.receipt_comment = comment; context.SubmitChanges(); } } } }
private void Add() { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); try { if (textBox1.Text.Length > 0) { var list = from n in context.genre where n.genre_name == textBox1.Text select n; genre data = new genre { genre_name = textBox1.Text }; context.genre.InsertOnSubmit(data); context.SubmitChanges(); textBox1.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_save_Click(object sender, EventArgs e) { DBClassDataContext context = new DBClassDataContext(Globals.ConnectionString); if (dataGridView1.RowCount <= 0) { return; } button_save.Enabled = false; //receipt作成 string num = textBox_Grade.Text + textBox_Class.Text + textBox_AttNum.Text; int receiptid = 0; var receipts = from n in context.receipt where n.receipt_seller == num select n; foreach (var m in receipts) { if (m.receipt_seller == Globals.seller_DONATE || m.receipt_seller == Globals.seller_EXT || m.receipt_seller == Globals.seller_LAGACY) { if (m.receipt_seller_exname == textBox_Name.Text) { if (MessageBox.Show(m.receipt_seller + " " + m.receipt_seller_exname + " " + "(" + m.receipt_id.ToString("'R'0000") + ")の票番はすでに存在しています。この票番を開きますか?", "登録確認", MessageBoxButtons.YesNo) == DialogResult.Yes) { receiptid = m.receipt_id; break; } } } else if (MessageBox.Show(m.receipt_seller + " " + m.receipt_seller_exname + " " + "(" + m.receipt_id.ToString("'R'0000") + ")の票番はすでに存在しています。この票番を開きますか?", "登録確認", MessageBoxButtons.YesNo) == DialogResult.Yes) { receiptid = m.receipt_id; break; } } if (receiptid == 0) { var newreceipt = new receipt() { receipt_seller = num, receipt_seller_exname = textBox_Name.Text, receipt_time = DateTime.Now, }; if (num == Globals.seller_EXT) { newreceipt.receipt_comment = "メールアドレス:" + email; } context.receipt.InsertOnSubmit(newreceipt); try { context.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } receiptid = newreceipt.receipt_id; } //グリッド読み込み foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["ItemName"].Value != null) { int price; int number; int volume; int.TryParse(row.Cells["ItemNum"].Value.ToString(), out number); int.TryParse(row.Cells["ItemPrice"].Value.ToString(), out price); if (row.Cells["ItemVol"].ValueType == typeof(string)) { int.TryParse(row.Cells["ItemVol"].Value.ToString(), out volume); } else { volume = 0; } context.item.InsertOnSubmit(new item() { item_receipt_id = receiptid, item_receipt_time = DateTime.Now, item_name = row.Cells["ItemName"].Value.ToString(), item_number = number, item_tagprice = price, item_return = (bool)(row.Cells["ItemReturn"].Value ?? false), item_volumes = volume, item_comment = (row.Cells["ItemComment"].Value ?? "").ToString(), item_supplement = supplement }); } } //最終処理 try { context.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { var wrreceipt = from n in wrcontext.wrreceipt where n.receipt_id == int.Parse(textBox_No.Text) select n; foreach (var q in wrreceipt) { q.receipt_registerd = true; } wrcontext.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } MessageBox.Show("登録しました(票番:R" + receiptid.ToString() + ")"); supplement = false; label_supplement.Visible = supplement; textBox_No.Focus(); textBox_No.SelectAll(); }
private void button_teisei_Click(object sender, EventArgs e) { if (this.curItem_id == 0) { return; } string def; var context = new DBClassDataContext(Globals.ConnectionString); if (curItem_id < 90000) { var curItem = context.item.Single(n => n.item_id == curItem_id); if (curItem.item_sellprice.HasValue) { def = curItem.item_sellprice.ToString(); } else { def = "未売却"; } while (true) { string res; DialogResult dres = InputBox.ShowIntDialog("修正後の売価を入力してください\n商品名: " + curItem.item_name, "売価修正", def, out res); if (dres == DialogResult.Cancel) { return; } else { int baika; if (!int.TryParse(res, out baika)) { def = "不正な文字列です"; continue; } curItem.item_sellprice = baika; curItem.item_selltime = DateTime.Now; curItem.item_sell_operator = this.nowOperator; while (true) { try { context.SubmitChanges(); break; } catch { if (Globals.ConnectionString.State == ConnectionState.Open) { } else { this.label_error.Text = "監査に失敗しました。"; return; } } } this.DoKansaItem(curItem_id); this.label_error.Text = "金額訂正が完了しました"; return; } } } else { MessageBox.Show("福袋の値段修正はできません。個別に修正してください。"); } }
private void DoKansaItem(int it_id) { this.curItem_id = it_id; var context = new DBClassDataContext(Globals.ConnectionString); if (it_id < 90000) { item it = context.item.Single(n => n.item_id == it_id); context.Connection.Close(); this.textBox_ban.Text = it.item_id.ToString(); this.textBox_name.BackColor = SystemColors.Control; this.textBox_name.Text = it.item_name; this.textBox_teika.Text = it.item_tagprice.ToString("#,##0"); this.textBox_nebiki.Text = it.item_return /*FIXME*/ ? "×" : "○"; if (it.item_sellprice.HasValue) { if (it.item_sellprice.Value == it.item_tagprice) { this.textBox_baika.Text = "-- " + it.item_sellprice.Value.ToString(); } else { this.textBox_baika.Text = it.item_sellprice.Value.ToString(); } if (it.item_sell_operator != null) { this.textBox_sellop.Text = [email protected](n => n.operator_id == it.item_sell_operator).operator_name; } else { this.textBox_sellop.Text = "不明"; } this.textBox_selltime.Text = Globals.getTimeString(it.item_selltime); this.button_mibai.Enabled = true; this.button_teisei.Enabled = true; this.textBox_baika.BackColor = SystemColors.Control; if (it.item_kansa_end.HasValue) { //監査済み this.label_error.Text = "監査対象ではありません。本日の販売ではない可能性が。"; this.label_error.Visible = true; } else { if (this.GetKansaFlag(it).HasValue) { List <@operator> lop = (from n in context.@operator where n.operator_id == GetKansaFlag(it).Value select n).ToList(); if (lop.Count() == 0) { this.label_error.Text = "だれかが既に監査したようです"; } else { this.label_error.Text = lop[0].operator_name + " が既に監査しています"; } this.label_error.Visible = true; } else { /* * System.Threading.Thread t = new System.Threading.Thread( * delegate(object item) * { * item itemmm = (item)item; * this.SetKansaFlag(itemmm, this.nowOperator); * context.SubmitChanges(); * } * ); * * t.IsBackground = true; * t.Start(it); */ this.SetKansaFlag(it, this.nowOperator); context.SubmitChanges(); this.label_error.Text = "監査しました。次の品番を入力してね"; this.RefreshRemain(); } } } else { this.button_teisei.Enabled = true; this.button_mibai.Enabled = false; this.textBox_baika.Text = "未売却"; this.textBox_baika.BackColor = Color.LightPink; this.textBox_sellop.Text = null; this.textBox_selltime.Text = null; this.label_error.Text = "未売却の商品は監査できません"; this.label_error.Visible = true; } } else { box bx = context.box.Single(n => n.box_id == (it_id - 90000)); List <item> it = (from n in context.item where n.item_box_id == bx.box_id select n).ToList(); context.Connection.Close(); this.textBox_ban.Text = bx.box_id.ToString(); this.textBox_name.BackColor = SystemColors.Control; this.textBox_name.Text = bx.box_comment; int sellpprice = (from n in it select n.item_sellprice.HasValue ? n.item_sellprice.Value : 0).Sum(); this.textBox_teika.Text = sellpprice.ToString("#,##0"); this.textBox_nebiki.Text = "×"; if (sellpprice > 0) { this.textBox_baika.Text = sellpprice.ToString(); if (it[0].item_sell_operator != null) { this.textBox_sellop.Text = [email protected](n => n.operator_id == it[0].item_sell_operator).operator_name; } else { this.textBox_sellop.Text = "不明"; } this.textBox_selltime.Text = Globals.getTimeString(it[0].item_selltime); this.button_mibai.Enabled = true; this.button_teisei.Enabled = true; this.textBox_baika.BackColor = SystemColors.Control; bool kansaend = true; foreach (var q in it) { if (!q.item_kansa_end.HasValue) { kansaend = false; } } if (kansaend) { //監査済み this.label_error.Text = "監査対象ではありません。本日の販売ではない可能性が。"; this.label_error.Visible = true; } else { if (this.GetKansaFlag(it[0]).HasValue) { List <@operator> lop = (from n in context.@operator where n.operator_id == GetKansaFlag(it[0]).Value select n).ToList(); if (lop.Count() == 0) { this.label_error.Text = "だれかが既に監査したようです"; } else { this.label_error.Text = lop[0].operator_name + " が既に監査しています"; } this.label_error.Visible = true; } else { /* * System.Threading.Thread t = new System.Threading.Thread( * delegate(object item) * { * item itemmm = (item)item; * this.SetKansaFlag(itemmm, this.nowOperator); * context.SubmitChanges(); * } * ); * * t.IsBackground = true; * t.Start(it); */ foreach (var q in it) { this.SetKansaFlag(q, this.nowOperator); } while (true) { try { context.SubmitChanges(); break; } catch { if (Globals.ConnectionString.State == ConnectionState.Open) { } else { this.label_error.Text = "監査に失敗しました。"; return; } } } this.label_error.Text = "監査しました。次の品番を入力してね"; this.RefreshRemain(); } } } else { this.button_teisei.Enabled = true; this.button_mibai.Enabled = false; this.textBox_baika.Text = "未売却"; this.textBox_baika.BackColor = Color.LightPink; this.textBox_sellop.Text = null; this.textBox_selltime.Text = null; this.label_error.Text = "未売却の商品は監査できません"; this.label_error.Visible = true; } } this.textBox_ban.Focus(); this.textBox_ban.SelectAll(); }
protected void btSave_Click(object sender, EventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); clsSecurity security = new clsSecurity(); clsIO IO = new clsIO(); string strDetailSub = string.Empty; string strDetail = txtDetail.Text.Replace("<p>", ""); strDetail = strDetail.Replace("</p>", ""); string PicFull = "null"; string PicThumb = "null"; string pathPhoto = "/Images/Event/"; string pathImages = @"\Images\Event\"; string outError; //upload Photo to server if (txtImgFull.HasFile) { //Full Images if (IO.UploadPhoto(txtImgFull, pathPhoto, "f_pic" + DateTime.Now.ToString("yyyyMMddHHmmss"), 5120, 0, 0, "", 0, out outError, out PicFull) == false) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + outError.ToString() + "')", true); return; } else { PicFull = pathImages + "" + PicFull; } } else { PicFull = lblImagesFull.Text.Trim(); } if (txtImgThum.HasFile) { //Thumb Images if (IO.UploadPhoto(txtImgThum, pathPhoto, "t_pic" + DateTime.Now.ToString("yyyyMMddHHmmss"), 2048, 0, 0, "", 0, out outError, out PicThumb) == false) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + outError.ToString() + "')", true); return; } else { PicThumb = pathImages + "" + PicThumb; } } else { PicThumb = lblImagesThumb.Text.Trim(); } //insert data to database try { if (txtDetail.Text.Length >= 200) { strDetailSub = "<p>" + strDetail.Substring(0, 200) + ".....</p>"; } else { strDetailSub = "<p>" + strDetail + ".....</p>"; } //Insert new Event if (string.IsNullOrEmpty(lblUID.Text) == true) { Event tbevent = new Event(); //Assign values for insert into database tbevent.Subject = txtSubject.Text.Trim(); tbevent.Detail = txtDetail.Text; tbevent.PicFull = PicFull; tbevent.PicThumbnail = PicThumb; tbevent.DepartmentUID = 1; tbevent.ActiveDateFrom = Convert.ToDateTime(txtDateFrom.Text); tbevent.ActiveDateTo = Convert.ToDateTime(txtDateTo.Text); tbevent.Remark = txtRemark.Text.Trim(); tbevent.CWhen = DateTime.Now; tbevent.CUser = Convert.ToInt32(security.LoginUID); tbevent.MWhen = DateTime.Now; tbevent.MUser = Convert.ToInt32(security.LoginUID); tbevent.StatusFlag = rdbActive.Checked == true ? "A" : "D"; tbevent.LanguageUID = Convert.ToInt32(ddlLanguage.SelectedValue); tbevent.DetailSub = strDetailSub; tbevent.MetaKeywords = txtMetaKeywords.Text.Trim(); tbevent.MetaDescription = txtMetaDescription.Text.Trim(); //Insert data of Event to database db.Events.InsertOnSubmit(tbevent); } else //Update existing Event { var tbEvent = from ev in db.Events where ev.UID == Convert.ToInt32(lblUID.Text.Trim()) select ev; foreach (Event ev in tbEvent) { ev.Subject = txtSubject.Text.Trim(); ev.Detail = txtDetail.Text; ev.PicFull = PicFull; ev.PicThumbnail = PicThumb; ev.DepartmentUID = 1; ev.ActiveDateFrom = Convert.ToDateTime(txtDateFrom.Text); ev.ActiveDateTo = Convert.ToDateTime(txtDateTo.Text); ev.Remark = txtRemark.Text.Trim(); ev.MWhen = DateTime.Now; ev.MUser = Convert.ToInt32(security.LoginUID); ev.StatusFlag = rdbActive.Checked == true ? "A" : "D"; ev.MetaKeywords = txtMetaKeywords.Text.Trim(); ev.MetaDescription = txtMetaDescription.Text.Trim(); try { ev.LanguageUID = Convert.ToInt32(ddlLanguage.SelectedValue); } catch (Exception ex) { ex.ToString(); } ev.DetailSub = strDetailSub; } } db.SubmitChanges(); clsColorBox clsColorBox = new clsColorBox(); clsColorBox.Refresh(); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "closeWindow", "<script language='javascript'>parent.$.colorbox.close();</script>"); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } }
private void SetConfig(DbConfig config_data, DBClassDataContext context) { List <config> config_list = new List <config>(); config_list.Add(new config { config_name = "bumonname", config_value = config_data.bumonnname }); config_list.Add(new config { config_name = "companyname", config_value = config_data.companyname }); config_list.Add(new config { config_name = "symbolcolor_argb", config_value = config_data.symbolcolor.ToArgb().ToString() }); config_list.Add(new config { config_name = "bumontextcolor_argb", config_value = config_data.bumontextcolor.ToArgb().ToString() }); config_list.Add(new config { config_name = "barcodeprefix", config_value = config_data.barcodeplefix.ToString() }); config_list.Add(new config { config_name = "itemname_imeon", config_value = config_data.itemname_iemon.ToString() }); config_list.Add(new config { config_name = "entertotab", config_value = config_data.entertotab.ToString() }); config_list.Add(new config { config_name = "connection_string", config_value = config_data.connectionstring }); //データベース処理 try { context.config.DeleteAllOnSubmit(context.config); foreach (config data in config_list) { context.config.InsertOnSubmit(data); } context.SubmitChanges(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void textBox_baika_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && curItem_id != 0) { if (this.curItem_id == 0) { return; } var context = new DBClassDataContext(Globals.ConnectionString); if (curItem_id < 90000) { item curItem = context.item.Single(n => n.item_id == curItem_id); string s = this.textBox_baika.Text; int baika; if (s == "-") { baika = curItem.item_tagprice; } else { if (!int.TryParse(s, out baika)) { this.textBox_baika_err(); return; } if (baika > 999999) { this.textBox_baika_err(); return; } } if (curItem.item_sellprice.HasValue && curItem.item_sellprice.Value == baika) { } else { privItem_id = curItem_id; privItemSellPrice = curItem.item_sellprice; privItemSellTime = curItem.item_selltime; privItemSellOperatorId = curItem.item_sell_operator; curItem.item_sellprice = baika; curItem.item_selltime = DateTime.Now; curItem.item_sell_operator = this.nowOperator; } } else { box curbox = context.box.Single(n => n.box_id == (curItem_id - 90000)); List <item> curItems = (from n in context.item where n.item_box_id == curbox.box_id select n).ToList(); string s = this.textBox_baika.Text; int baika; if (s == "-") { baika = curItems.Sum(n => n.item_sellprice_bag.Value); if (curItems[0].item_sellprice.HasValue && curItems.Sum(n => n.item_sellprice.Value) == baika) { } else { privItem_id = 0; privItemSellPrice = null; privItemSellTime = null; privItemSellOperatorId = null; foreach (var q in curItems) { q.item_sellprice = q.item_sellprice_bag; q.item_selltime = DateTime.Now; q.item_sell_operator = this.nowOperator; } } } } System.Threading.Thread t = new System.Threading.Thread( delegate() { bool success = false; while (!success) { try { context.SubmitChanges(); break; } catch (Exception ex) { if (Globals.ConnectionString.State == ConnectionState.Open) { } else { MessageBox.Show(ex.Message); return; } } } }); t.Start(); this.textBox_ban_err("次の品番を入力してね"); } }