<
asp:datagrid id
=
"
dg_RecItem
"
runat
=
"
server
"
CssClass
=
"
Datagrid
"
Width
=
"
100%
"
AutoGenerateColumns
=
"
False
"
PageSize = " 5 " >
< SelectedItemStyle CssClass = " dgdSelectedItem " ></ SelectedItemStyle >
< EditItemStyle CssClass = " dgdEditItem " ></ EditItemStyle >
< ItemStyle CssClass = " dgdItem " ></ ItemStyle >
< HeaderStyle Wrap = " False " CssClass = " dgdHead " ></ HeaderStyle >
< Columns >
< asp:TemplateColumn HeaderText = " Select " >
< ItemTemplate >
< asp:LinkButton id = " lkbtn_select " runat = " server " Text = "" CausesValidation = " false " CommandName = " Select "
CssClass = " dgdNoButton " ></ asp:LinkButton >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " catg_flg " HeaderText = " Rec Type Flag " ></ asp:BoundColumn >
< asp:BoundColumn HeaderText = " Rec Item No " ></ asp:BoundColumn >
< asp:BoundColumn HeaderText = " GR No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " po_no " HeaderText = " PO No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " po_sheet_no " HeaderText = " PO Sheet No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " item_no " HeaderText = " PO Item No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " MS_Code " HeaderText = " MS Code " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " qty_order " HeaderText = " Qty Order " ></ asp:BoundColumn >
< asp:TemplateColumn HeaderText = " Qty Recv " >
< ItemTemplate >
< asp:TextBox id = " txt_QtyRecv " runat = " server " Width = " 90% " Visible = " False " ></ asp:TextBox >
< asp:Button id = " btn_QtyRecv " runat = " server " CssClass = " button1 " Visible = " False " Text = " Submit "
CommandName = " Submit_Qty " ></ asp:Button >
< asp:Label id = " lbl_QtyRecv " runat = " server " ></ asp:Label >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " OS_QTY " HeaderText = " O/S Qty " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " UNIT_PRCE " HeaderText = " Unit Price " ></ asp:BoundColumn >
< asp:TemplateColumn HeaderText = " Amt Recv " >
< ItemTemplate >
< asp:TextBox id = " txt_AmtRecv " runat = " server " Width = " 90% " Visible = " False " ></ asp:TextBox >
< asp:Label id = " lbl_AmtRecv " runat = " server " ></ asp:Label >
< asp:Button id = " btn_AmtRecv " runat = " server " CssClass = " button1 " Visible = " False " Text = " Submit "
CommandName = " Submit_Amt " ></ asp:Button >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " OS_RECAMT " HeaderText = " O/S Receipt Amt " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " recv_by_amt " HeaderText = " recv_by_amt " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " PARTIAL_RCV_FLG " HeaderText = " PARTIAL_RCV_FLG " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " TAG_ISSUE_FLG " HeaderText = " TAG_ISSUE_FLG " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " RECVD_AMT " HeaderText = " RECVD_AMT " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " QTY_RECVD " HeaderText = " QTY_RECVD " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " STORE_SPEC_NO " HeaderText = " STORE_SPEC_NO " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " comp_No " HeaderText = " compNo " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " dis_tag " HeaderText = " DisableTag " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " DATE_CANCEL " HeaderText = " DATE_CANCEL " ></ asp:BoundColumn >
</ Columns >
< PagerStyle HorizontalAlign = " Right " PageButtonCount = " 3 " Mode = " NumericPages " ></ PagerStyle >
</ asp:datagrid >
PageSize = " 5 " >
< SelectedItemStyle CssClass = " dgdSelectedItem " ></ SelectedItemStyle >
< EditItemStyle CssClass = " dgdEditItem " ></ EditItemStyle >
< ItemStyle CssClass = " dgdItem " ></ ItemStyle >
< HeaderStyle Wrap = " False " CssClass = " dgdHead " ></ HeaderStyle >
< Columns >
< asp:TemplateColumn HeaderText = " Select " >
< ItemTemplate >
< asp:LinkButton id = " lkbtn_select " runat = " server " Text = "" CausesValidation = " false " CommandName = " Select "
CssClass = " dgdNoButton " ></ asp:LinkButton >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " catg_flg " HeaderText = " Rec Type Flag " ></ asp:BoundColumn >
< asp:BoundColumn HeaderText = " Rec Item No " ></ asp:BoundColumn >
< asp:BoundColumn HeaderText = " GR No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " po_no " HeaderText = " PO No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " po_sheet_no " HeaderText = " PO Sheet No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " item_no " HeaderText = " PO Item No " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " MS_Code " HeaderText = " MS Code " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " qty_order " HeaderText = " Qty Order " ></ asp:BoundColumn >
< asp:TemplateColumn HeaderText = " Qty Recv " >
< ItemTemplate >
< asp:TextBox id = " txt_QtyRecv " runat = " server " Width = " 90% " Visible = " False " ></ asp:TextBox >
< asp:Button id = " btn_QtyRecv " runat = " server " CssClass = " button1 " Visible = " False " Text = " Submit "
CommandName = " Submit_Qty " ></ asp:Button >
< asp:Label id = " lbl_QtyRecv " runat = " server " ></ asp:Label >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " OS_QTY " HeaderText = " O/S Qty " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " UNIT_PRCE " HeaderText = " Unit Price " ></ asp:BoundColumn >
< asp:TemplateColumn HeaderText = " Amt Recv " >
< ItemTemplate >
< asp:TextBox id = " txt_AmtRecv " runat = " server " Width = " 90% " Visible = " False " ></ asp:TextBox >
< asp:Label id = " lbl_AmtRecv " runat = " server " ></ asp:Label >
< asp:Button id = " btn_AmtRecv " runat = " server " CssClass = " button1 " Visible = " False " Text = " Submit "
CommandName = " Submit_Amt " ></ asp:Button >
</ ItemTemplate >
</ asp:TemplateColumn >
< asp:BoundColumn DataField = " OS_RECAMT " HeaderText = " O/S Receipt Amt " ></ asp:BoundColumn >
< asp:BoundColumn DataField = " recv_by_amt " HeaderText = " recv_by_amt " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " PARTIAL_RCV_FLG " HeaderText = " PARTIAL_RCV_FLG " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " TAG_ISSUE_FLG " HeaderText = " TAG_ISSUE_FLG " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " RECVD_AMT " HeaderText = " RECVD_AMT " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " QTY_RECVD " HeaderText = " QTY_RECVD " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " STORE_SPEC_NO " HeaderText = " STORE_SPEC_NO " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " comp_No " HeaderText = " compNo " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " dis_tag " HeaderText = " DisableTag " ></ asp:BoundColumn >
< asp:BoundColumn Visible = " False " DataField = " DATE_CANCEL " HeaderText = " DATE_CANCEL " ></ asp:BoundColumn >
</ Columns >
< PagerStyle HorizontalAlign = " Right " PageButtonCount = " 3 " Mode = " NumericPages " ></ PagerStyle >
</ asp:datagrid >
CS:
private
void
dg_RecItem_ItemCommand(
object
source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (Session["POReceiptStatus"].ToString() == "Query")
{
this.dg_RecItem_ItemCommand2(source,e);
}
else
{
this.dg_RecItem_ItemCommand1(source,e);
}
}
{
if (Session["POReceiptStatus"].ToString() == "Query")
{
this.dg_RecItem_ItemCommand2(source,e);
}
else
{
this.dg_RecItem_ItemCommand1(source,e);
}
}
private
void
dg_RecItem_ItemCommand1(
object
source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//Insert Mode
int oldIndex = (int)ViewState["oldSelectedItemIndex"];
switch(e.CommandName)
{
case "Select":
if(oldIndex != -1)
{
if(e.Item.Cells[14].Text == "N")
{
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("lbl_QtyRecv")).Visible = true;
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("txt_QtyRecv")).Visible = false;
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("btn_QtyRecv")).Visible = false;
}
if(e.Item.Cells[14].Text == "Y")
{
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("lbl_AmtRecv")).Visible = true;
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("txt_AmtRecv")).Visible = false;
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("btn_AmtRecv")).Visible = false;
}
if(e.Item.ItemIndex==oldIndex)
{
ViewState["oldSelectedItemIndex"]=-1;
}
}
else
{
if(e.Item.Cells[14].Text == "N")
{
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Visible = false;
((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Visible = true;
((Button)e.Item.Cells[9].FindControl("btn_QtyRecv")).Visible = true;
//set focus
if((e.Item.Cells[15].Text == "1")&&(e.Item.Cells[16].Text == "2"))
{
btn_Component.Enabled = true;
}
else
{
btn_Component.Enabled = false;
}
}
else
{
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Visible = false;
((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Visible = true;
((Button)e.Item.Cells[12].FindControl("btn_AmtRecv")).Visible = true;
}
ViewState["oldSelectedItemIndex"] = e.Item.ItemIndex;
}
break;
case "Submit_Qty":
string qtyRecv = ((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Text.Trim();
decimal qtyOrder = Convert.ToDecimal(e.Item.Cells[8].Text.Trim());
decimal qty = 0;
try
{
qty = DBConvert.toDecimal(((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Text.Trim());
}
catch(Exception ex)
{
string errorMessage = ex.Message;
string info = culturemanager.cust_GetString("Err_InvalidQuantity");
ShowMessage(info);
break;
}
if(e.Item.Cells[10].Text == " " || e.Item.Cells[10].Text == "")
{
e.Item.Cells[10].Text = "0";
}
if( qty > 0 && qty > (Convert.ToInt32(e.Item.Cells[10].Text.Trim())) && dsTable.Rows[0]["recv_by_amt"].ToString() == "N" )
{
if(errorDispose("WEPO0026"))break;
}
if(e.Item.Cells[16].Text == "2" && qty < qtyOrder && qtyRecv != (Session["qtyChecked"].ToString()))
{
if(errorDispose("WEPO0023"))
{
this.btn_Component.Enabled = true;
break;
}
}
try
{
decimal qtyRecvNum =0;
int os_qty = 0;
try
{
qtyRecvNum = Convert.ToDecimal(qtyRecv);
}
catch
{
string script = "<script> alert('" + culturemanager.cust_GetString("err_receipt6")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
if(e.Item.Cells[10].Text.Trim()!= "")
{
os_qty = Convert.ToInt32(e.Item.Cells[10].Text.Trim());
}
if((0 <= qtyRecvNum ) && (qtyRecvNum <= os_qty))
{
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Visible = true;
((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Visible = false;
((Button)e.Item.Cells[9].FindControl("btn_QtyRecv")).Visible = false;
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Text = qtyRecv;
this.dg_RecItem.SelectedIndex = -1;
ViewState["oldSelectedItemIndex"] = -1;
}
else if(qtyRecvNum > 0 && qtyRecvNum > os_qty && dsTable.Rows[0]["recv_by_amt"].ToString() == "N" )//hfw 20070525
{
if(errorDispose("WEPO0026"))break;
}
else
{
string script = "<script> alert('" + culturemanager.cust_GetString("err_receipt8")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
decimal amtRecv = Math.Round(Convert.ToDecimal(e.Item.Cells[11].Text.Trim())*qtyRecvNum,2);
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text = amtRecv.ToString();
decimal totalAmt = txt_TotalAmt.Text.Trim()!=""?Convert.ToDecimal(txt_TotalAmt.Text.Trim()):0;
decimal totalAmount=(qtyOrder-(os_qty-qtyRecvNum))*(Convert.ToDecimal(e.Item.Cells[11].Text.Trim()));
txt_TotalAmt.Text=totalAmount.ToString();
Session["qtyChecked"]=-1;
}
catch(Exception ee)
{
string strSystemName = ConfigurationSettings.AppSettings["SystemName"];
string strSystemLog = ConfigurationSettings.AppSettings["SystemLog"];
if(!EventLog.SourceExists(strSystemName))
{
EventLog.CreateEventSource(strSystemName,strSystemLog);
}
EventLog mylog = new EventLog();
mylog.Source = strSystemName;
mylog.WriteEntry(ee.Message + "---" + Request.Url.ToString(),EventLogEntryType.Error);
string error = ee.Message;
string script = "<script> alert('" + error + "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
break;
case "Submit_Amt":
string strQtyRecvA=((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text.Trim();
decimal recvAmt = 0;
try
{
recvAmt = DBConvert.toDecimal(((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Text.Trim());
}
catch(Exception ex)
{
string errorMessage = ex.Message;
string info = culturemanager.cust_GetString("Err_InvalidNumber");
ShowMessage(info);
break;
}
try
{
double oldAmtRecv = 0;
double amtRecvNum = 0;
double os_amt = 0;
string amtRecv = ((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Text.Trim();
amtRecvNum = Convert.ToDouble(amtRecv);
if(e.Item.Cells[13].Text.Trim() != "" && e.Item.Cells[13].Text.Trim() != " ")
{
os_amt = Convert.ToDouble(e.Item.Cells[13].Text.Trim());
}
if (os_amt == 0)
{
if((0 <=amtRecvNum ) && (amtRecvNum <= os_amt))
{
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Visible = true;
((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Visible = false;
((Button)e.Item.Cells[12].FindControl("btn_AmtRecv")).Visible = false;
oldAmtRecv = ((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text!=""?
Convert.ToDouble(((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text.Trim()):0;
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text = amtRecv;
this.dg_RecItem.SelectedIndex = -1;
ViewState["oldSelectedItemIndex"] = -1;
}
else if( amtRecvNum > 0 && amtRecvNum > os_amt && dsTable.Rows[0]["recv_by_amt"].ToString() == "Y" )//hfw 20070525
{
amtRecvNum = 0 ;
Rhombus.Common.Error.errorDispose("WEPO0290" , "3" );
break;
}
else
{
string script = "<script> alert('" + culturemanager.cust_GetString("Err_InvalidNumber")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Text =
string.Format(strFormat,amtRecvNum/Convert.ToDouble(e.Item.Cells[11].Text.Trim()));
e.Item.Cells[10].Text = string.Format(strFormat,(os_amt - amtRecvNum)/Convert.ToDouble(e.Item.Cells[11].Text.Trim()));
double totalAmt = txt_TotalAmt.Text.Trim()!=""?Convert.ToDouble(txt_TotalAmt.Text.Trim()):0;
txt_TotalAmt.Text = (totalAmt + amtRecvNum - oldAmtRecv).ToString();
}
catch(Exception ee)
{
string strSystemName = ConfigurationSettings.AppSettings["SystemName"];
string strSystemLog = ConfigurationSettings.AppSettings["SystemLog"];
if(!EventLog.SourceExists(strSystemName))
{
EventLog.CreateEventSource(strSystemName,strSystemLog);
}
EventLog mylog = new EventLog();
mylog.Source = strSystemName;
mylog.WriteEntry(ee.Message + "---" + Request.Url.ToString(),EventLogEntryType.Error);
string error = ee.Message;
string script = "<script> alert('" + error + "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
break;
default:
break;
}
}
{
//Insert Mode
int oldIndex = (int)ViewState["oldSelectedItemIndex"];
switch(e.CommandName)
{
case "Select":
if(oldIndex != -1)
{
if(e.Item.Cells[14].Text == "N")
{
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("lbl_QtyRecv")).Visible = true;
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("txt_QtyRecv")).Visible = false;
(dg_RecItem.Items[oldIndex].Cells[9].FindControl("btn_QtyRecv")).Visible = false;
}
if(e.Item.Cells[14].Text == "Y")
{
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("lbl_AmtRecv")).Visible = true;
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("txt_AmtRecv")).Visible = false;
(dg_RecItem.Items[oldIndex].Cells[12].FindControl("btn_AmtRecv")).Visible = false;
}
if(e.Item.ItemIndex==oldIndex)
{
ViewState["oldSelectedItemIndex"]=-1;
}
}
else
{
if(e.Item.Cells[14].Text == "N")
{
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Visible = false;
((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Visible = true;
((Button)e.Item.Cells[9].FindControl("btn_QtyRecv")).Visible = true;
//set focus
if((e.Item.Cells[15].Text == "1")&&(e.Item.Cells[16].Text == "2"))
{
btn_Component.Enabled = true;
}
else
{
btn_Component.Enabled = false;
}
}
else
{
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Visible = false;
((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Visible = true;
((Button)e.Item.Cells[12].FindControl("btn_AmtRecv")).Visible = true;
}
ViewState["oldSelectedItemIndex"] = e.Item.ItemIndex;
}
break;
case "Submit_Qty":
string qtyRecv = ((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Text.Trim();
decimal qtyOrder = Convert.ToDecimal(e.Item.Cells[8].Text.Trim());
decimal qty = 0;
try
{
qty = DBConvert.toDecimal(((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Text.Trim());
}
catch(Exception ex)
{
string errorMessage = ex.Message;
string info = culturemanager.cust_GetString("Err_InvalidQuantity");
ShowMessage(info);
break;
}
if(e.Item.Cells[10].Text == " " || e.Item.Cells[10].Text == "")
{
e.Item.Cells[10].Text = "0";
}
if( qty > 0 && qty > (Convert.ToInt32(e.Item.Cells[10].Text.Trim())) && dsTable.Rows[0]["recv_by_amt"].ToString() == "N" )
{
if(errorDispose("WEPO0026"))break;
}
if(e.Item.Cells[16].Text == "2" && qty < qtyOrder && qtyRecv != (Session["qtyChecked"].ToString()))
{
if(errorDispose("WEPO0023"))
{
this.btn_Component.Enabled = true;
break;
}
}
try
{
decimal qtyRecvNum =0;
int os_qty = 0;
try
{
qtyRecvNum = Convert.ToDecimal(qtyRecv);
}
catch
{
string script = "<script> alert('" + culturemanager.cust_GetString("err_receipt6")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
if(e.Item.Cells[10].Text.Trim()!= "")
{
os_qty = Convert.ToInt32(e.Item.Cells[10].Text.Trim());
}
if((0 <= qtyRecvNum ) && (qtyRecvNum <= os_qty))
{
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Visible = true;
((TextBox)e.Item.Cells[9].FindControl("txt_QtyRecv")).Visible = false;
((Button)e.Item.Cells[9].FindControl("btn_QtyRecv")).Visible = false;
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Text = qtyRecv;
this.dg_RecItem.SelectedIndex = -1;
ViewState["oldSelectedItemIndex"] = -1;
}
else if(qtyRecvNum > 0 && qtyRecvNum > os_qty && dsTable.Rows[0]["recv_by_amt"].ToString() == "N" )//hfw 20070525
{
if(errorDispose("WEPO0026"))break;
}
else
{
string script = "<script> alert('" + culturemanager.cust_GetString("err_receipt8")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
decimal amtRecv = Math.Round(Convert.ToDecimal(e.Item.Cells[11].Text.Trim())*qtyRecvNum,2);
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text = amtRecv.ToString();
decimal totalAmt = txt_TotalAmt.Text.Trim()!=""?Convert.ToDecimal(txt_TotalAmt.Text.Trim()):0;
decimal totalAmount=(qtyOrder-(os_qty-qtyRecvNum))*(Convert.ToDecimal(e.Item.Cells[11].Text.Trim()));
txt_TotalAmt.Text=totalAmount.ToString();
Session["qtyChecked"]=-1;
}
catch(Exception ee)
{
string strSystemName = ConfigurationSettings.AppSettings["SystemName"];
string strSystemLog = ConfigurationSettings.AppSettings["SystemLog"];
if(!EventLog.SourceExists(strSystemName))
{
EventLog.CreateEventSource(strSystemName,strSystemLog);
}
EventLog mylog = new EventLog();
mylog.Source = strSystemName;
mylog.WriteEntry(ee.Message + "---" + Request.Url.ToString(),EventLogEntryType.Error);
string error = ee.Message;
string script = "<script> alert('" + error + "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
break;
case "Submit_Amt":
string strQtyRecvA=((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text.Trim();
decimal recvAmt = 0;
try
{
recvAmt = DBConvert.toDecimal(((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Text.Trim());
}
catch(Exception ex)
{
string errorMessage = ex.Message;
string info = culturemanager.cust_GetString("Err_InvalidNumber");
ShowMessage(info);
break;
}
try
{
double oldAmtRecv = 0;
double amtRecvNum = 0;
double os_amt = 0;
string amtRecv = ((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Text.Trim();
amtRecvNum = Convert.ToDouble(amtRecv);
if(e.Item.Cells[13].Text.Trim() != "" && e.Item.Cells[13].Text.Trim() != " ")
{
os_amt = Convert.ToDouble(e.Item.Cells[13].Text.Trim());
}
if (os_amt == 0)
{
if((0 <=amtRecvNum ) && (amtRecvNum <= os_amt))
{
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Visible = true;
((TextBox)e.Item.Cells[12].FindControl("txt_AmtRecv")).Visible = false;
((Button)e.Item.Cells[12].FindControl("btn_AmtRecv")).Visible = false;
oldAmtRecv = ((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text!=""?
Convert.ToDouble(((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text.Trim()):0;
((Label)e.Item.Cells[12].FindControl("lbl_AmtRecv")).Text = amtRecv;
this.dg_RecItem.SelectedIndex = -1;
ViewState["oldSelectedItemIndex"] = -1;
}
else if( amtRecvNum > 0 && amtRecvNum > os_amt && dsTable.Rows[0]["recv_by_amt"].ToString() == "Y" )//hfw 20070525
{
amtRecvNum = 0 ;
Rhombus.Common.Error.errorDispose("WEPO0290" , "3" );
break;
}
else
{
string script = "<script> alert('" + culturemanager.cust_GetString("Err_InvalidNumber")+ "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
((Label)e.Item.Cells[9].FindControl("lbl_QtyRecv")).Text =
string.Format(strFormat,amtRecvNum/Convert.ToDouble(e.Item.Cells[11].Text.Trim()));
e.Item.Cells[10].Text = string.Format(strFormat,(os_amt - amtRecvNum)/Convert.ToDouble(e.Item.Cells[11].Text.Trim()));
double totalAmt = txt_TotalAmt.Text.Trim()!=""?Convert.ToDouble(txt_TotalAmt.Text.Trim()):0;
txt_TotalAmt.Text = (totalAmt + amtRecvNum - oldAmtRecv).ToString();
}
catch(Exception ee)
{
string strSystemName = ConfigurationSettings.AppSettings["SystemName"];
string strSystemLog = ConfigurationSettings.AppSettings["SystemLog"];
if(!EventLog.SourceExists(strSystemName))
{
EventLog.CreateEventSource(strSystemName,strSystemLog);
}
EventLog mylog = new EventLog();
mylog.Source = strSystemName;
mylog.WriteEntry(ee.Message + "---" + Request.Url.ToString(),EventLogEntryType.Error);
string error = ee.Message;
string script = "<script> alert('" + error + "');</script>";
this.RegisterStartupScript("alert",script);
break;
}
break;
default:
break;
}
}