public void FError(string StrError) { MessageLB.Text = StrError; AlertPanel_ModalPopupExtender.Show(); //ModalPopupExtender Pop = (ModalPopupExtender)Page.FindControl(""); //Pop.Show(); }
protected void MaterialGV_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "到料") { using (SqlConnection conn1 = new SqlConnection(strConnectString)) { GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer; string StrSite = "", StrOrd = "", StrOrdSam = "", StrColor_id = ""; StrSite = MaterialGV.Rows[row.RowIndex].Cells[1].Text; StrOrd = MaterialGV.Rows[row.RowIndex].Cells[2].Text; StrOrdSam = MaterialGV.Rows[row.RowIndex].Cells[4].Text; StrColor_id = MaterialGV.Rows[row.RowIndex].Cells[5].Text.Replace(" ", ""); SqlCommand command1 = conn1.CreateCommand(); SqlTransaction transaction1; conn1.Open(); transaction1 = conn1.BeginTransaction("UpdateOrdSam"); command1.Connection = conn1; command1.Transaction = transaction1; try { command1.CommandText = string.Format(@" update ordc_sample set material_flag = 1 ,material_check_date =getdate() where site = '{0}' and ord_nbr = '{1}' and doc_item = '{2}' and color_id= '{3}' and material_flag = 0 ", StrSite, StrOrd, StrOrdSam, StrColor_id); command1.ExecuteNonQuery(); transaction1.Commit(); DbInit(); //MessageLB.Text = "訂單樣衣料到料日上傳完畢"; } catch (Exception ex1) { try { Log.ErrorLog(ex1, "訂單樣衣料到料日上傳失敗 :", "Sales017.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "訂單樣衣料到料日上傳失敗 Error:", "Sales017.aspx"); } finally { transaction1.Rollback(); MessageLB.Text = "訂單樣衣料到料日上傳失敗請連絡MIS"; AlertPanel_ModalPopupExtender.Show(); } } finally { conn1.Close(); conn1.Dispose(); command1.Dispose(); //Session.RemoveAll(); } } } }
private void DBBind() { if (string.IsNullOrEmpty(採購單TB.Text) && string.IsNullOrEmpty(款號TB.Text) && string.IsNullOrEmpty(供應商TB.Text)) { MessageLB.Text = "請輸入搜尋條件"; AlertPanel_ModalPopupExtender.Show(); } else if (string.IsNullOrEmpty(款號TB.Text) && !string.IsNullOrEmpty(供應商TB.Text)) { MessageLB.Text = "使用供應商查詢需輸入款號"; AlertPanel_ModalPopupExtender.Show(); } else { StringBuilder sb = new StringBuilder(); sb.Append(@"SELECT [採購單號碼] ,[主副料] ,[訂單號碼] ,[款號] ,[採購單狀態] FROM [dbo].[View未核准採購單] where 1=1 "); if (!string.IsNullOrEmpty(採購單TB.Text)) { sb.AppendFormat(" and 採購單號碼 in {0}", 字串處理.字串多筆資料搜尋(採購單TB.Text).ToString()); } if (!string.IsNullOrEmpty(款號TB.Text)) { sb.AppendFormat(" and 款號 in {0}", 字串處理.字串多筆資料搜尋(款號TB.Text).ToString()); } if (!string.IsNullOrEmpty(供應商TB.Text)) { sb.AppendFormat(" and (供應商簡稱 ='{0}' or 供應商代號 = '{0}')", 供應商TB.Text); } if (sb.Length > 0) { DataTable dt = new DataTable(); using (SqlConnection Conn = new SqlConnection(strConnectString)) { SqlDataAdapter myAdapter = new SqlDataAdapter(sb.ToString(), Conn); myAdapter.Fill(dt); //---- 這時候執行SQL指令。取出資料,放進 DataSet。 } 確認GV.DataSource = dt; 確認GV.DataBind(); if (dt.Rows.Count > 0) { } else { MessageLB.Text = "搜尋不到資料"; AlertPanel_ModalPopupExtender.Show(); } } } }
protected void SearchBT_Click(object sender, EventArgs e) { MsgLB.Text = ""; if (!string.IsNullOrEmpty(快遞時間TB.Text.Trim())) { DateTime 快遞時間 = Convert.ToDateTime(快遞時間TB.Text.Trim()); string 快遞單號 = (string.IsNullOrEmpty(快遞單號TB.Text.Trim())) ? "" : 快遞單號TB.Text.Trim(); //var c = db.快遞單.Where(p => p.提單日期.Month == 快遞時間.Month && p.提單日期.Year == 快遞時間.Year && p.提單日期.Day == 快遞時間.Day); var c = db.快遞單.Where(p => p.提單日期 == 快遞時間 && p.IsDeleted == false); if (快遞單號.Length > 0) { c = c.Where(p => p.提單號碼.Contains(快遞單號)); } if (c.Count() > 1) { Session["提單日期"] = 快遞時間TB.Text.Trim(); SelectPanel_ModalPopupExtender.Show(); } else { if (c.Count() > 0) { foreach (var item in c) { if (F_確認檢貨(item.id)) { MsgLB.Text = "快遞單櫃台已檢貨"; } HeadDB(item.id); } Show(true); } else { MessageLB.Text = "日期沒有快遞單,請櫃台新增快遞單資料"; AlertPanel_ModalPopupExtender.Show(); } } } }
protected void DeleteBT_Click(object sender, EventArgs e) { int iid = 0; int.TryParse(idHF.Value, out iid); var x = db.快遞單.Find(iid); if (x != null) { try { x.IsDeleted = true; x.修改日期 = DateTime.Now; db.SaveChanges(); idHF.Value = null; } catch (Exception ex) { try { Log.ErrorLog(ex, "Delete Error :", "MGT001.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "Delete Error Error:", "MGT001.aspx"); } } } else { MessageLB.Text = "沒有快遞單資料"; AlertPanel_ModalPopupExtender.Show(); } Show(false); }
public void F_ErrorShow(string strError) { MessageLB.Text = strError; AlertPanel_ModalPopupExtender.Show(); }
protected void UpDateBT_Click(object sender, EventArgs e) { int icount = 0; if (確認GV.Rows.Count > 0) { icount = 確認GV.Rows.Count; StringBuilder sb = new StringBuilder(); CheckBox CHK = (CheckBox)(確認GV.HeaderRow.Cells[0].FindControl("全部更新CB")); //List<string> L櫃號 = new List<string>(); for (int i = 0; i < icount; i++) { if (CHK.Checked) { sb.Append(string.IsNullOrEmpty(確認GV.Rows[i].Cells[1].Text.Trim()) ? "" : (sb.Length > 0)?" , '" + 確認GV.Rows[i].Cells[1].Text.Trim() + "' ": " '" + 確認GV.Rows[i].Cells[1].Text.Trim() + "' "); } else { CheckBox CHK2 = (CheckBox)(確認GV.Rows[i].Cells[0].FindControl("UpdateCB")); if (CHK2.Checked) { sb.Append(string.IsNullOrEmpty(確認GV.Rows[i].Cells[1].Text.Trim()) ? "" : (sb.Length > 0) ? " , '" + 確認GV.Rows[i].Cells[1].Text.Trim() + "' " : " '" + 確認GV.Rows[i].Cells[1].Text.Trim() + "' "); } } } if (sb.Length > 0) { using (SqlConnection conn1 = new SqlConnection(strConnectString)) { SqlCommand command1 = conn1.CreateCommand(); SqlTransaction transaction1; conn1.Open(); transaction1 = conn1.BeginTransaction("UpdatePur"); command1.Connection = conn1; command1.Transaction = transaction1; try { command1.CommandText = string.Format(@" update purc_purchase_master set pur_head_status='OP',pur_approver='105020',pur_approve_date=getdate() where pur_head_status in ('NA','O1') and pur_nbr in ( {0} ) ", sb.ToString()); command1.ExecuteNonQuery(); command1.Parameters.Clear(); command1.CommandText = string.Format(@" update purc_purchase_detail set pur_detail_status='OP' where pur_detail_status in ('NA','O1') and pur_nbr in ( {0} ) ", sb.ToString()); command1.ExecuteNonQuery(); transaction1.Commit(); DBBind(); MessageLB.Text = "採購單核准完畢"; AlertPanel_ModalPopupExtender.Show(); } catch (Exception ex1) { try { Log.ErrorLog(ex1, "採購單核准失敗 :", "MIS007.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "採購單核准失敗 Error:", "MIS007.aspx"); } finally { transaction1.Rollback(); MessageLB.Text = "採購單核准失敗請連絡MIS"; AlertPanel_ModalPopupExtender.Show(); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('核准失敗請連絡MIS');</script>"); } } finally { conn1.Close(); conn1.Dispose(); command1.Dispose(); //Session.RemoveAll(); } } } } }
protected void Button1_Click(object sender, EventArgs e) { string savePath = Server.MapPath(@"~\ExcelUpLoad\Salse\SIZE\"); string tempFolder = System.IO.Path.GetTempPath(); // Get folder string FileName = FileUpload1.FileName.ToString(); // Get xml file name string strpo = FileName.Substring(FileName.Length - 12, 8); //"GREGIA_20180605203002208_02075624.XML" savePath = savePath + FileName; if (string.IsNullOrEmpty(FileUpload1.FileName)) { MessageLB.Text = "請選擇檔案"; AlertPanel_ModalPopupExtender.Show(); } else { try { MessageLB.Text = ""; FileUpload1.SaveAs(savePath); DataSet ds = new DataSet(); //透過DataSet的ReadXml方法來讀取Xmlreader資料 ds.ReadXml(savePath); //建立DataTable並將DataSet中的第0個Table資料給DataTable DataTable dt = ds.Tables["ColorSize"]; //轉換數量類型 dt.Columns.Add("數量", typeof(int), "Convert(Quantity,'System.Int32')"); DataTable dt1 = ds.Tables["PrePack"]; DataTable dt2 = ds.Tables["Shipment"]; DataTable dt3 = ds.Tables["Item"]; DataTable dtColor = new DataTable(), dtSize = new DataTable(); dtColor = dt.DefaultView.ToTable(true, new string[] { "Color" }); dtSize = dt.DefaultView.ToTable(true, new string[] { "Size" }); DataTable TempTable = new DataTable(); TempTable.Columns.Add("訂單Style"); TempTable.Columns.Add("客戶PO"); TempTable.Columns.Add("目的地代號"); TempTable.Columns.Add("PO別"); TempTable.Columns.Add("Style"); TempTable.Columns.Add("FOB單價"); TempTable.Columns.Add("客戶交期"); TempTable.Columns.Add("顏色(英文)"); if (dtSize.Rows.Count > 0) { for (int iSizeCount = 0; iSizeCount < dtSize.Rows.Count; iSizeCount++) { TempTable.Columns.Add(dtSize.Rows[iSizeCount][0].ToString().ToUpper().Trim()); } } //----不考慮多單價,所有item都會相同 //for (int po資料筆數 = 0; po資料筆數 < dt3.Rows.Count; po資料筆數++) //{ //} for (int i顏色數量 = 0; i顏色數量 < dtColor.Rows.Count; i顏色數量++) { DataRow row; row = TempTable.NewRow(); //----不考慮多單價,所有item都會相同 row["訂單Style"] = dt3.Rows[0]["ItemBuyerOrderNo"]; row["FOB單價"] = dt3.Rows[0]["ItemUnitPriceTotal"]; //---- row["客戶PO"] = strpo; row["客戶交期"] = dt2.Rows[0]["ShipmentDeliveryDate"]; row["顏色(英文)"] = dtColor.Rows[i顏色數量][0]; for (int iSizeCount = 0; iSizeCount < dtSize.Rows.Count; iSizeCount++) { object obtest; obtest = dt.Compute("sum(數量)", "Color = '" + dtColor.Rows[i顏色數量][0].ToString() + "' and Size = '" + dtSize.Rows[iSizeCount][0] + "'"); row[dtSize.Rows[iSizeCount][0].ToString()] = obtest.ToString().ToUpper().Trim(); } TempTable.Rows.Add(row); } if (TempTable.Columns.Count > 0) { for (int i = 0; i < TempTable.Columns.Count; i++) { if (TempTable.Columns[i].ColumnName.IndexOf(" (") > 0) { //刪除多餘尺寸說明 TempTable.Columns[i].ColumnName = TempTable.Columns[i].ColumnName.Substring(0, TempTable.Columns[i].ColumnName.IndexOf(" (")); } } } ReferenceCode.ConvertToExcel xx = new ReferenceCode.ConvertToExcel(); xx.ExcelWithNPOI(TempTable, @"xlsx"); } catch (Exception ex) { MessageLB.Text = ex.ToString(); AlertPanel_ModalPopupExtender.Show(); } } }
protected void SamGV_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName == "上傳" || e.CommandName == "刪除") { GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer; string StrSite = "", StrSam_nbr = "", StrUpdateData = ""; //StringBuilder sb = new StringBuilder(); StrSite = SamGV.Rows[row.RowIndex].Cells[1].Text; StrSam_nbr = SamGV.Rows[row.RowIndex].Cells[2].Text; using (SqlConnection conn1 = new SqlConnection(strConnectString)) { SqlCommand command1 = conn1.CreateCommand(); SqlTransaction transaction1; conn1.Open(); transaction1 = conn1.BeginTransaction("UpdateSam"); command1.Connection = conn1; command1.Transaction = transaction1; try { StrUpdateData = (e.CommandName == "上傳") ?"'" + DateTime.Now.ToString("yyyy-MM-dd") + "'": "null"; command1.CommandText = string.Format(@" update samc_reqm set s_real_arrival_date= {0} where sam_nbr = '{1}' and site = '{2}' ", StrUpdateData, StrSam_nbr, StrSite); command1.ExecuteNonQuery(); transaction1.Commit(); //DBBind(); DbInit(); MessageLB.Text = "主副料到期日上傳完畢"; AlertPanel_ModalPopupExtender.Show(); } catch (Exception ex1) { try { Log.ErrorLog(ex1, "主副料到期日上傳失敗 :", "Sample012.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "主副料到期日上傳 Error:", "Sample012.aspx"); } finally { transaction1.Rollback(); MessageLB.Text = "主副料到期日上傳失敗請連絡MIS"; AlertPanel_ModalPopupExtender.Show(); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('核准失敗請連絡MIS');</script>"); } } finally { conn1.Close(); conn1.Dispose(); command1.Dispose(); //Session.RemoveAll(); } } } }