<asp:Panel ID="Add_Panel" runat="server" BackColor="White" Height="90px">
<table style="width: 230px;">
<tr>
<td class="settingHeader" style="font-style: italic; font-weight: bold"> 請輸入廠款號:
</td>
<td align="right">
<asp:LinkButton ID="Add_Cancel" runat="server" Font-Size="Small" ForeColor="Gray">關閉</asp:LinkButton>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel7" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width: 230px;">
<tr style="height: 80px">
<td class="settingContent" align="left" style="padding-left: 15px; vertical-align: top;">
<asp:TextBox ID="Add_TextBox" runat="server" Width="150px"></asp:TextBox>
<asp:Button ID="Add_Confirm" runat="server" ForeColor="#333333" Text="確定" />
<br />
<asp:Label ID="Add_Message" runat="server" Font-Size="Small" ForeColor="Red"></asp:Label>
<asp:LinkButton ID="Add_Yes_Button" runat="server" Visible="False" Font-Size="Small">是</asp:LinkButton>
<asp:LinkButton ID="Add_No_Button" runat="server" Visible="False" Font-Size="Small">否</asp:LinkButton>
<br />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton5"
PopupControlID="Add_Panel" DropShadow="true" BackgroundCssClass="modalBackground"
Enabled="True" CancelControlID="Add_Cancel">
</asp:ModalPopupExtender>
Protected Sub Add_Confirm_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_Confirm.Click
Add_Yes_Button.Visible = False
Add_No_Button.Visible = False
Dim New_ID As String = ""
Dim Original_Front As String = ""
Dim Original_Back As String = ""
Using cn As New SqlConnection()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("Sample_Room_ProgressConnectionString").ConnectionString
cn.Open()
Dim sqlStr1 As String = "SELECT * FROM Style WHERE Factory_Style_No = '" & Trim(Add_TextBox.Text) & "'"
Dim sda As New SqlDataAdapter(sqlStr1, cn)
Dim ds As New DataSet()
sda.Fill(ds)
cn.Close()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("CostingConnectionString").ConnectionString
cn.Open()
Dim sqlStr As String = "INSERT INTO Costing(Factory_Style_No, Customer_Style_No, Customer_Brand, Writer, Sales_Team)" & _
_
"VALUES(@Factory_Style_No, @Customer_Style_No, @Customer_Brand, @Writer, @Sales_Team)"
Dim cmd As New SqlCommand(sqlStr, cn)
cmd.Parameters.Add(New SqlParameter("@Factory_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Customer_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Customer_Brand", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Writer", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Sales_Team", SqlDbType.NVarChar))
If ds.Tables(0).Rows.Count = 0 Then
Add_Message.Text = "*沒此款號資料!" ',仍要建立此成本表嗎?"
'Add_Yes_Button.Visible = True
'Add_No_Button.Visible = True
Return
Else
Original_Front = ds.Tables(0).Rows(0).Item("Picture_Front")
Original_Back = ds.Tables(0).Rows(0).Item("Picture_Back")
cmd.Parameters("@Factory_Style_No").Value = ds.Tables(0).Rows(0).Item("Factory_Style_No")
cmd.Parameters("@Customer_Style_No").Value = ds.Tables(0).Rows(0).Item("Customer_Style_No")
cmd.Parameters("@Customer_Brand").Value = ds.Tables(0).Rows(0).Item("Customer_Brand")
cmd.Parameters("@Writer").Value = Session("People_Name")
cmd.Parameters("@Sales_Team").Value = Session("Sales_Team")
If cmd.ExecuteNonQuery() = 1 Then
Dim sqlCmd As New SqlCommand("Select @@IDENTITY", cn)
Dim dr As SqlDataReader = sqlCmd.ExecuteReader()
If dr.Read() Then
New_ID = dr.GetValue(0)
End If
dr.Close()
End If
End If
End Using
Call add_pic_from_style(New_ID, Original_Front, Original_Back)
Call add_plus(New_ID)
Response.Redirect("Costing_Details.aspx?Costing_ID=" & New_ID)
End Sub
Protected Sub Add_No_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_No_Button.Click
ModalPopupExtender1.Hide()
End Sub
Protected Sub Add_Yes_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_Yes_Button.Click
Using cn As New SqlConnection()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("CostingConnectionString").ConnectionString
cn.Open()
Dim sqlStr As String = "INSERT INTO Costing(Factory_Style_No, Writer)" & _
_
"VALUES(@Factory_Style_No, @Writer)"
Dim cmd As New SqlCommand(sqlStr, cn)
cmd.Parameters.Add(New SqlParameter("@Factory_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Writer", SqlDbType.NVarChar))
cmd.Parameters("@Factory_Style_No").Value = Trim(Add_TextBox.Text)
cmd.Parameters("@Writer").Value = Session("People_Name")
If cmd.ExecuteNonQuery() = 1 Then
Dim sqlCmd As New SqlCommand("Select @@IDENTITY", cn)
Dim dr As SqlDataReader = sqlCmd.ExecuteReader()
If dr.Read() Then
Call add_plus(dr.GetValue(0))
Response.Redirect("Costing_Details.aspx?Costing_ID=" & dr.GetValue(0))
End If
dr.Close()
End If
End Using
End Sub
<asp:Panel ID="Add_Panel" runat="server" BackColor="White" Height="90px">
<table style="width: 230px;">
<tr>
<td class="settingHeader" style="font-style: italic; font-weight: bold"> 請輸入廠款號:
</td>
<td align="right">
<asp:LinkButton ID="Add_Cancel" runat="server" Font-Size="Small" ForeColor="Gray">關閉</asp:LinkButton>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel7" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width: 230px;">
<tr style="height: 80px">
<td class="settingContent" align="left" style="padding-left: 15px; vertical-align: top;">
<asp:TextBox ID="Add_TextBox" runat="server" Width="150px"></asp:TextBox>
<asp:Button ID="Add_Confirm" runat="server" ForeColor="#333333" Text="確定" />
<br />
<asp:Label ID="Add_Message" runat="server" Font-Size="Small" ForeColor="Red"></asp:Label>
<asp:LinkButton ID="Add_Yes_Button" runat="server" Visible="False" Font-Size="Small">是</asp:LinkButton>
<asp:LinkButton ID="Add_No_Button" runat="server" Visible="False" Font-Size="Small">否</asp:LinkButton>
<br />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton5"
PopupControlID="Add_Panel" DropShadow="true" BackgroundCssClass="modalBackground"
Enabled="True" CancelControlID="Add_Cancel">
</asp:ModalPopupExtender>
Protected Sub Add_Confirm_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_Confirm.Click
Try
Add_Yes_Button.Visible = False
Add_No_Button.Visible = False
Dim New_ID As String = ""
Dim Original_Front As String = ""
Dim Original_Back As String = ""
Using cn As New SqlConnection()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("Sample_Room_ProgressConnectionString").ConnectionString
cn.Open()
Dim sqlStr1 As String = "SELECT * FROM Style WHERE Factory_Style_No = '" & Trim(Add_TextBox.Text) & "'"
Dim sda As New SqlDataAdapter(sqlStr1, cn)
Dim ds As New DataSet()
sda.Fill(ds)
cn.Close()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("CostingConnectionString").ConnectionString
cn.Open()
Dim sqlStr As String = "INSERT INTO Costing(Factory_Style_No, Customer_Style_No, Customer_Brand, Writer)" & _
_
"VALUES(@Factory_Style_No, @Customer_Style_No, @Customer_Brand, @Writer)"
Dim cmd As New SqlCommand(sqlStr, cn)
cmd.Parameters.Add(New SqlParameter("@Factory_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Customer_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Customer_Brand", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Writer", SqlDbType.NVarChar))
If ds.Tables(0).Rows.Count = 0 Then
Add_Message.Text = "*沒此款號資料!" ',仍要建立此成本表嗎?"
'Add_Yes_Button.Visible = True
'Add_No_Button.Visible = True
Return
Else
Original_Front = ds.Tables(0).Rows(0).Item("Picture_Front").ToString()
Original_Back = ds.Tables(0).Rows(0).Item("Picture_Back").ToString()
cmd.Parameters("@Factory_Style_No").Value = ds.Tables(0).Rows(0).Item("Factory_Style_No").ToString()
cmd.Parameters("@Customer_Style_No").Value = ds.Tables(0).Rows(0).Item("Customer_Style_No").ToString()
cmd.Parameters("@Customer_Brand").Value = ds.Tables(0).Rows(0).Item("Customer_Brand").ToString()
cmd.Parameters("@Writer").Value = Session("People_Name").ToString()
If cmd.ExecuteNonQuery() = 1 Then
Dim sqlCmd As New SqlCommand("Select @@IDENTITY", cn)
Dim dr As SqlDataReader = sqlCmd.ExecuteReader()
If dr.Read() Then
New_ID = dr.GetValue(0)
End If
dr.Close()
End If
End If
End Using
Call add_pic_from_style(New_ID, Original_Front, Original_Back)
Call add_plus(New_ID)
Response.Redirect("Costing_Details.aspx?Costing_ID=" & New_ID)
Catch ex As Exception
Message.Text = ex.Message.ToString
End Try
End Sub
Protected Sub Add_No_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_No_Button.Click
ModalPopupExtender1.Hide()
End Sub
Protected Sub Add_Yes_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Add_Yes_Button.Click
Try
Using cn As New SqlConnection()
cn.ConnectionString = ConfigurationManager.ConnectionStrings("CostingConnectionString").ConnectionString
cn.Open()
Dim sqlStr As String = "INSERT INTO Costing(Factory_Style_No, Writer)" & _
_
"VALUES(@Factory_Style_No, @Writer)"
Dim cmd As New SqlCommand(sqlStr, cn)
cmd.Parameters.Add(New SqlParameter("@Factory_Style_No", SqlDbType.NVarChar))
cmd.Parameters.Add(New SqlParameter("@Writer", SqlDbType.NVarChar))
cmd.Parameters("@Factory_Style_No").Value = Trim(Add_TextBox.Text)
cmd.Parameters("@Writer").Value = Session("People_Name")
If cmd.ExecuteNonQuery() = 1 Then
Dim sqlCmd As New SqlCommand("Select @@IDENTITY", cn)
Dim dr As SqlDataReader = sqlCmd.ExecuteReader()
If dr.Read() Then
Call add_plus(dr.GetValue(0))
Response.Redirect("Costing_Details.aspx?Costing_ID=" & dr.GetValue(0))
End If
dr.Close()
End If
End Using
Catch ex As Exception
Message.Text = ex.Message.ToString
End Try
End Sub