Пример #1
0
 private void DbInit()
 {
     using (SqlConnection Conn = new SqlConnection(strConnectString))
     {
         DataTable      dt        = new DataTable();
         string         sqlstr    = selectsql();
         SqlDataAdapter myAdapter = new SqlDataAdapter(sqlstr, Conn);
         myAdapter.Fill(dt);
         AcrTicketGV.DataSource = dt;
         AcrTicketGV.DataBind();
     }
 }
Пример #2
0
        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>");
            }
        }