protected void SelectAllBT_Click(object sender, EventArgs e) { Button bt = (Button)AcrTicketGV.HeaderRow.Cells[0].FindControl("SelectAllBT"); int icount = AcrTicketGV.Rows.Count; Boolean bCheck = false; if (icount > 0) { if (bt.Text == "全選") { bCheck = true; bt.Text = "全取消"; } else { bt.Text = "全選"; } for (int i = 0; i < icount; i++) { CheckBox chk = (CheckBox)AcrTicketGV.Rows[i].Cells[0].FindControl("CheckBox1"); chk.Checked = bCheck; } } POPPanel_ModalPopupExtender.Show(); }
protected void PhoneGV_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { //SELECT uid,[phone] as '分機' // ,[name] as '員工姓名' // ,[empolyee_no] as '員工編號' // ,[eng_name] as '英文姓名' // ,[email] as 'Email' // ,[skype_account] as 'Skype' // ,[location] as '位置' // FROM[dbo].[GGFPhoneNumber] UidLB.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[1].Text.ToString(); PhoneLB.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[2].Text.ToString(); NameTB.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[3].Text.ToString().Replace(" ", ""); NumberBT.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[4].Text.ToString().Replace(" ", ""); EngName.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[5].Text.ToString().Replace(" ", ""); EmailTB.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[6].Text.ToString().Replace(" ", ""); SkypeBT.Text = PhoneGV.Rows[e.NewSelectedIndex].Cells[7].Text.ToString().Replace(" ", ""); LocationDDL.SelectedValue = PhoneGV.Rows[e.NewSelectedIndex].Cells[8].Text.ToString(); POPPanel_ModalPopupExtender.Show(); }
protected void SaveBT_Click(object sender, EventArgs e) { int icount = AcrTicketGV.Rows.Count; //Boolean bCheck = false; if (icount > 0) { int iCbcount = 0; string strAcrAdd = "", strAcrDelete = "", strPkdAdd = "", strPkdDelete = ""; double dAcr = 0, dPkd = 0; for (int i = 0; i < icount; i++) { CheckBox chk = (CheckBox)AcrTicketGV.Rows[i].Cells[0].FindControl("CheckBox1"); //chk.Checked = bCheck; //Add if (chk.Checked) { if (AcrTicketGV.Rows[i].Cells[4].Text == "應收") { strAcrAdd += " ," + AcrTicketGV.Rows[i].Cells[1].Text; dAcr += Convert.ToDouble(AcrTicketGV.Rows[i].Cells[6].Text); } else { strPkdAdd += " ," + AcrTicketGV.Rows[i].Cells[1].Text; dPkd += Convert.ToDouble(AcrTicketGV.Rows[i].Cells[7].Text); } iCbcount++; } //Delete else { if (AcrTicketGV.Rows[i].Cells[4].Text == "應收") { strAcrDelete += " ," + AcrTicketGV.Rows[i].Cells[1].Text; } else { strPkdDelete += " ," + AcrTicketGV.Rows[i].Cells[1].Text; } } } if (strAcrAdd.Length > 0 || strPkdAdd.Length > 0) { if (dAcr * 0.8 > dPkd) { string strAcrTaxID = ""; using (SqlConnection conn1 = new SqlConnection(strConnectString)) { SqlCommand command1 = conn1.CreateCommand(); SqlTransaction transaction1; conn1.Open(); transaction1 = conn1.BeginTransaction("createStyle"); command1.Connection = conn1; command1.Transaction = transaction1; try { command1.CommandText = string.Format(@"UPDATE [dbo].[acr_trn_check] SET [AcrTaxID] = {0} , CheckFlag ='NA' WHERE uid in ({1}) ", Session["AcrId"], strAcrAdd.Substring(2)); command1.ExecuteNonQuery(); //command1.Parameters.Clear(); if (strAcrDelete.Length > 0) { command1.CommandText = string.Format(@"UPDATE [dbo].[acr_trn_check] SET [AcrTaxID] = Null , CheckFlag ='NA' WHERE uid in ({0}) ", strAcrDelete.Substring(2)); command1.ExecuteNonQuery(); } command1.CommandText = string.Format(@"UPDATE [dbo].[purc_pkd_for_acr] SET [AcrTaxID] = {0} , CheckFlag ='NA' WHERE uid in ({1}) ", Session["AcrId"], strPkdAdd.Substring(2)); command1.ExecuteNonQuery(); if (strPkdDelete.Length > 0) { command1.CommandText = string.Format(@"UPDATE [dbo].[purc_pkd_for_acr] SET [AcrTaxID] = Null , CheckFlag ='NA' WHERE uid in ({0}) ", strPkdDelete.Substring(2)); command1.ExecuteNonQuery(); } //command1.CommandText = string.Format(@"UPDATE [dbo].[AcrTax] SET [Flag] = 2 WHERE uid = {0} ", strAcrTaxID); //command1.ExecuteNonQuery(); transaction1.Commit(); } catch (Exception ex1) { try { Log.ErrorLog(ex1, "Updata Error AcrTaxID:" + strAcrTaxID, "TAX006.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "Updata Error2 AcrTaxID:" + strAcrTaxID, "TAX006.aspx"); } finally { MessageLB.Text = "更新失敗請與資訊部聯絡"; transaction1.Rollback(); } } finally { conn1.Close(); conn1.Dispose(); command1.Dispose(); } } } else { MessageLB.Text = string.Format("包裝金額 {0} * 0.8 = {1} 大於應收金額 {2} '", dAcr, dAcr * 0.8, dPkd); //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", string.Format("<script>alert('包裝金額 {0} * 0.8 = {1} 大於應收金額 {2} ');</script>", dAcr, dAcr * 0.8 , dPkd)); POPPanel_ModalPopupExtender.Show(); } } else { //Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('請選擇應收與包裝資料');</script>"); MessageLB.Text = "請選擇應收與包裝資料"; POPPanel_ModalPopupExtender.Show(); } } }
protected void ACRGV_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { string strStyleNo = ACRGV.Rows[e.NewSelectedIndex].Cells[1].Text.ToString().Replace(" ", ""); //string strWhere = ; if (string.IsNullOrEmpty(strStyleNo) == false) { if (Ds.Tables.Contains("acr_trn_check")) { Ds.Tables.Remove("acr_trn_check"); } Ds.Tables.Add(GetData.SQLToDataSet(strConnectString, "select * from acr_trn_check where style_no = '" + strStyleNo + "'", "acr_trn_check", "TAX004.aspx")); if (Ds.Tables.Contains("purc_pkd_check")) { Ds.Tables.Remove("purc_pkd_check"); } Ds.Tables.Add(GetData.SQLToDataSet(strConnectString, "select * from purc_pkd_for_acr where cus_item_no ='" + strStyleNo + "'", "purc_pkd_check", "TAX004.aspx")); int icheck1 = 0, icheck2 = 0; icheck1 = (Ds.Tables["acr_trn_check"].Rows.Count > 0) ? 0 : 1; icheck2 = (Ds.Tables["purc_pkd_check"].Rows.Count > 0) ? 0 : 1; if (icheck1 == 0 && icheck2 == 0) { DataTable dt = new DataTable("AcrTable"); DataColumn column; DataRow row; // Create new DataColumn, set DataType, // ColumnName and add to DataTable. column = new DataColumn(); column.DataType = System.Type.GetType("System.Int32"); column.ColumnName = "id"; //column.ReadOnly = true; //column.Unique = true; // Add the Column to the DataColumnCollection. dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "style_no"; dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.DateTime"); column.ColumnName = "DATE"; dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "TYPE"; dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Double"); column.ColumnName = "MONEY"; dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.Double"); column.ColumnName = "AMT"; dt.Columns.Add(column); column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "nbr"; dt.Columns.Add(column); for (int i = 0; i < Ds.Tables["acr_trn_check"].Rows.Count; i++) { row = dt.NewRow(); row["id"] = Ds.Tables["acr_trn_check"].Rows[i]["uid"].ToString(); row["style_no"] = Ds.Tables["acr_trn_check"].Rows[i]["style_no"].ToString(); row["DATE"] = Ds.Tables["acr_trn_check"].Rows[i]["acr_date"].ToString(); row["TYPE"] = "應收"; row["MONEY"] = Ds.Tables["acr_trn_check"].Rows[i]["foreign_amt"].ToString(); //row["AMT"] = Ds.Tables["acr_trn_check"].Rows[i]["uid"].ToString(); row["nbr"] = Ds.Tables["acr_trn_check"].Rows[i]["acr_nbr"].ToString(); dt.Rows.Add(row); } for (int i = 0; i < Ds.Tables["purc_pkd_check"].Rows.Count; i++) { row = dt.NewRow(); row["id"] = Ds.Tables["purc_pkd_check"].Rows[i]["uid"].ToString(); row["style_no"] = Ds.Tables["purc_pkd_check"].Rows[i]["cus_item_no"].ToString(); row["DATE"] = Ds.Tables["purc_pkd_check"].Rows[i]["create_date"].ToString(); row["TYPE"] = "包裝"; //row["MONEY"] = Ds.Tables["purc_pkd_check"].Rows[i]["uid"].ToString(); row["AMT"] = Ds.Tables["purc_pkd_check"].Rows[i]["customs_decleartion_amt"].ToString(); row["nbr"] = Ds.Tables["purc_pkd_check"].Rows[i]["pak_nbr"].ToString() + Ds.Tables["purc_pkd_check"].Rows[i]["pak_seq"].ToString(); dt.Rows.Add(row); } POPPanel_ModalPopupExtender.Show(); AcrTicketGV.DataSource = dt; if (Ds.Tables.Contains("AcrTable")) { Ds.Tables.Remove("AcrTable"); } Ds.Tables.Add(dt); AcrTicketGV.DataBind(); } else if (icheck1 == 1 && icheck2 == 0) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('請聯絡資訊部:應收無資料');</script>"); } else if (icheck2 == 1 && icheck1 == 0) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('請聯絡資訊部:包裝底稿無資料');</script>"); } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('請聯絡資訊部:應收與包裝底稿都無資料');</script>"); } } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('請聯絡資訊部:沒有Style_No');</script>"); } }
protected void DeleteBT_Click(object sender, EventArgs e) { if (Ds.Tables["purc_pkd_acr"].Rows.Count > 0) { //已被對應到應付單據 purc_pkd_acrGV.DataSource = Ds.Tables["purc_pkd_acr"]; purc_pkd_acrGV.DataBind(); POPPanel_ModalPopupExtender.Show(); } else { //未被對應到應付單據 if (Ds.Tables["SelectedPurc_pkm"].Rows.Count > 0) { using (SqlConnection conn1 = new SqlConnection(strConnectString)) { SqlCommand command1 = conn1.CreateCommand(); SqlTransaction transaction1; conn1.Open(); transaction1 = conn1.BeginTransaction("createOrder"); command1.Connection = conn1; command1.Transaction = transaction1; ReferenceCode.SysLog Log = new ReferenceCode.SysLog(); try { string strwhere = ""; for (int i = 0; i < Ds.Tables["SelectedPurc_pkm"].Rows.Count; i++) { if (i > 0) { strwhere += " , "; } strwhere += " '" + Ds.Tables["SelectedPurc_pkm"].Rows[i]["uid"] + "' "; } command1.CommandText = @"UPDATE [dbo].[purc_pkm_for_acr] SET [CheckFlag] = 'CA' ,[CheckModifyDate] =getdate() WHERE uid in (" + strwhere + ") "; command1.ExecuteNonQuery(); command1.Parameters.Clear(); command1.CommandText = @"UPDATE [dbo].[purc_pkd_for_acr] SET [CheckFlag] = 'CA' ,[CheckModifyDate] =getdate() WHERE acr_uid in (" + strwhere + ") "; command1.ExecuteNonQuery(); transaction1.Commit(); DBInit2();//Search Data DBInit(); } catch (Exception ex1) { try { Log.ErrorLog(ex1, "Delete Error", "TAX001.aspx"); } catch (Exception ex2) { Log.ErrorLog(ex2, "Delete Error2", "TAX001.aspx"); } finally { transaction1.Rollback(); } } finally { conn1.Close(); conn1.Dispose(); command1.Dispose(); } } } } }