protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow GR in GridView1.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here TextBox goods_id = (TextBox)GR.FindControl("lbl_GoodId"); TextBox goods_unit = (TextBox)GR.FindControl("lbl_ItemUnit"); TextBox goods_qty = (TextBox)GR.FindControl("lbl_ItemQty"); TextBox goods_price = (TextBox)GR.FindControl("lbl_ItemPrice"); int g_id = Convert.ToInt32(goods_id.Text.ToString()); string g_unit = Convert.ToString(goods_unit.Text.ToString()); string g_qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string g_price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); int LastInsertedId2 = 3261; int transaction_type = 1; con.Open(); string str3 = "insert into tenders_items (waybill_id, goods_id, unit_name, quantity, price, tr_type) Values ('" + LastInsertedId2 + "', '" + g_id + "', N'" + g_unit + "', '" + g_qty + "', '" + g_price + "', '" + transaction_type + "')"; SqlCommand strCmd3 = new SqlCommand(str3, con); strCmd3.ExecuteNonQuery(); con.Close(); } } }
protected void imgbtndiscard_Click(object sender, EventArgs e) { Int32 MsgId = 0; DataTable dtMain = new DataTable(); if (gridDelete.Rows.Count > 0) { foreach (GridViewRow GR in gridDelete.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgDetailId = Convert.ToInt32(gridDelete.DataKeys[GR.RowIndex].Value); dtMain = clsMessage.SelectMsgIdUsingMsgDetailId(MsgDetailId); if (dtMain.Rows.Count > 0) { MsgId = Convert.ToInt32(dtMain.Rows[0]["MsgId"].ToString()); } bool MsgMasterDelete = clsMessage.DeleteMsgMaster(MsgId); if (MsgMasterDelete == true) { lblmsg.Visible = true; lblmsg.Text = "Record deleted successfully"; SelectMsgforDeleteBox(); } } } } }
protected void Button2_Click(object sender, EventArgs e) { int amount = Convert.ToInt32(this.TextBox2.Text); int tagindex = -1; foreach (GridViewRow GR in this.GridView1.Rows) { CheckBox CB = (CheckBox)GR.FindControl("CheckBox1"); if (CB.Checked) { tagindex = GR.RowIndex; } } int bookamount = Convert.ToInt32(this.GridView1.Rows[tagindex].Cells[5].Text); int decrease = bookamount - amount; DataManage dm = new DataManage(); if (decrease > 0) { string sql = "update [Library].[library].[Book] set [Bamount] =" + decrease + "where [Bname] like '" + this.GridView1.Rows[tagindex].Cells[1].Text + "' and [Btype] like '" + this.GridView1.Rows[tagindex].Cells[2].Text + "' and [Bwriter] like '" + this.GridView1.Rows[tagindex].Cells[3].Text + "' and [Bpublish] like '" + this.GridView1.Rows[tagindex].Cells[4].Text + "'"; dm.ExecuteSql(sql); } else { string sql = "delete from [Library].[library].[Book] where [Bname] like '" + this.GridView1.Rows[tagindex].Cells[1].Text + "' and [Btype] like '" + this.GridView1.Rows[tagindex].Cells[2].Text + "' and [Bwriter] like '" + this.GridView1.Rows[tagindex].Cells[3].Text + "' and [Bpublish] like '" + this.GridView1.Rows[tagindex].Cells[4].Text + "'"; dm.ExecuteSql(sql); } Response.Write("<script>alert('出库成功!')</script>"); databind(); }
protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow GR in GridView1.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here Label MobileNum = (Label)GR.FindControl("mobile"); string str = MobileNum.Text; string other_nums = string.Empty; if (MobileNum.Text != null) { for (int i = 1; i < str.Length; i++) { if (Char.IsDigit(str[i])) { other_nums += str[i]; } var f_num = str[0].ToString(); var first_num = Convert.ToString(f_num.Replace("8", "5")); MobileNum.Text = first_num + other_nums; } } } } }
protected void imgbtnmovetoInbox_Click(object sender, EventArgs e) { bool Gcheck = false; bool UpdateMsgDetail = false; if (gridDelete.Rows.Count > 0) { foreach (GridViewRow GR in gridDelete.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Gcheck = true; break; } } if (Gcheck == false) { lblmsg.Text = "Please select atleast one deleted Message to move to Inbox."; lblmsg.Visible = true; return; } else { if (gridDelete.Rows.Count > 0) { foreach (GridViewRow GR in gridDelete.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgDetailId = Convert.ToInt32(gridDelete.DataKeys[GR.RowIndex].Value); UpdateMsgDetail = clsMessage.UpdateMsgDetail(MsgDetailId, 1); } } if (UpdateMsgDetail == true) { lblmsg.Visible = true; lblmsg.Text = "Messages are Successfully moved to Inbox."; SelectMsgforDeleteBox(); } } } } }
protected void imgbtndiscard_Click(object sender, EventArgs e) { bool Gcheck = false; if (gridDraft.Rows.Count > 0) { foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Gcheck = true; break; } } if (Gcheck == false) { lblmsg.Text = "Please select atleast one Draft Message to Delete."; pnlmsg.Visible = true; return; } else { bool MsgMasterDelete = false; foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgId = Convert.ToInt32(gridDraft.DataKeys[GR.RowIndex].Value); bool MsgDetailDelete = clsMessage.DeleteMsgDetail(MsgId); bool FileDelete = clsMessage.DeleteMsgFileAttachDetail(MsgId); MsgMasterDelete = clsMessage.DeleteMsgMaster(MsgId); } } if (MsgMasterDelete == true) { lblmsg.Visible = true; pnlmsg.Visible = true; lblmsg.Text = "Message Deleted Successfully."; SelectMsgforDraft(); } } } }
private void UpdateGrid() { int IndexRow = 0; int IndexMes = 0; string UnidValue = ""; int CodProducto = 0; string msgResultado = string.Empty; int CodProyecto = HttpContext.Current.Session["codProyecto"] == null?0: Convert.ToInt32(HttpContext.Current.Session["codProyecto"]); int TiempoProyeccion = HttpContext.Current.Session["TiempoProyeccion"] == null ? 0 : Convert.ToInt32(HttpContext.Current.Session["TiempoProyeccion"]); CodProducto = Request.QueryString["Id_Producto"] == null ? 0 : Convert.ToInt32(Request.QueryString["Id_Producto"]); CrearActualizarProductoVentas(TiempoProyeccion, CodProyecto, ref msgResultado, ref CodProducto); if (CodProducto > 0) { int TotalColl = _dttProductos.Columns.Count - 2; foreach (GridViewRow GR in GridView1.Rows) { string QueryUpdate = ""; if (IndexRow < 12) { for (int IndexCol = 1; IndexCol <= TiempoProyeccion; IndexCol++) { string FieldAnio = _dttProductos.Columns[IndexCol].ColumnName; FieldAnio = FieldAnio.Substring(3, 2).TrimStart(); string NomTextBox = "TextBox" + FieldAnio; if (GR.RowType == DataControlRowType.DataRow) { string FieldMes = _dttProductos.Columns[IndexCol].ColumnName; IndexMes = Convert.ToInt32(_dttProductos.Rows[IndexRow]["Periodos_"]); TextBox TextBoxValue = (TextBox)GR.FindControl(NomTextBox); TextBoxValue.Text = (TextBoxValue.Text == "" ? "0" : TextBoxValue.Text); UnidValue = TextBoxValue.Text.Replace(",", ""); } QueryUpdate += "UPDATE ProyectoProductoUnidadesVentas SET Unidades =" + UnidValue + " WHERE Codproducto=" + CodProducto + " and Mes=" + IndexMes + " and Ano=" + FieldAnio + "\n"; } IndexRow++; InsertUpdateProductos(QueryUpdate); } } precios(CodProducto.ToString(), TiempoProyeccion); } ClientScriptManager cm = this.ClientScript; cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'> alert('" + msgResultado + "'); location.href = '../Proyecto/PProyectoMercadoProyecciones.aspx' </script>"); }
protected void imgbtnsend_Click(object sender, EventArgs e) { bool Gcheck = false; bool UpdateMsg = false; if (gridDraft.Rows.Count > 0) { foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Gcheck = true; break; } } if (Gcheck == false) { lblmsg.Text = "Please select atleast one Draft Message to send."; pnlmsg.Visible = true; return; } else { foreach (GridViewRow GR in gridDraft.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgId = Convert.ToInt32(gridDraft.DataKeys[GR.RowIndex].Value); bool UpdateMsgMaster = clsMessage.UpdateMsgMasterforDraftSend(MsgId); UpdateMsg = clsMessage.UpdateMsgDetailusingMsgId(MsgId, 1); } } if (UpdateMsg == true) { pnlmsg.Visible = true; lblmsg.Visible = true; lblmsg.Text = "Message Sent Successfully."; SelectMsgforDraft(); } } } }
protected void imgbtndiscard_Click(object sender, EventArgs e) { if (gridInbox.Rows.Count > 0) { foreach (GridViewRow GR in gridInbox.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgDetailId = Convert.ToInt32(gridInbox.DataKeys[GR.RowIndex].Value); clsMessage.UpdateMsgDetail(MsgDetailId, 4); lblmsg.Text = "Message Discard Successfully"; lblmsg.Visible = true; pnlmsg.Visible = true; } } SelectMsgforInbox(); } }
protected void SaveWaybill_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow GR in GridView2.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here HiddenField goods_id = (HiddenField)GR.FindControl("HiddenField_GoodId"); Label goods_unit = (Label)GR.FindControl("lbl_ItemUnit"); Label goods_qty = (Label)GR.FindControl("lbl_ItemQty"); Label goods_price = (Label)GR.FindControl("lbl_ItemPrice"); int g_id = Convert.ToInt32(goods_id.Value.TrimStart()); string g_unit = Convert.ToString(goods_unit.Text.ToString()); string g_qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string g_price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); Response.Write("<script type='text/javascript'>alert('" + g_id + "')</script>"); } } }
protected void imgbtndiscard_Click(object sender, EventArgs e) { if (grdSentMailList.Rows.Count > 0) { foreach (GridViewRow GR in grdSentMailList.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkMsg"); if (chk.Checked == true) { Int32 MsgId = Convert.ToInt32(grdSentMailList.DataKeys[GR.RowIndex].Value); bool del = clsMessage.UpdateMsgMasterforSendDeleteExt(MsgId, "Deleted"); if (del == true) { pnlmsg.Visible = true; lblmsg.Text = "Record Discard Successfully"; lblmsg.Visible = true; } } } SelectMsgforSendBox(); } }
protected void Button2_Click(object sender, EventArgs e) { string str1 = ""; con.Close(); con.Open(); string str = " SELECT DISTINCT COUNT(dbo.MassEmailDetail.BusinessEmailID) AS Expr1, dbo.MassEmailDetail.BusinessEmailID FROM dbo.MassEmailDetail INNER JOIN dbo.MassemailMaster ON dbo.MassEmailDetail.MassemailMasterID = dbo.MassemailMaster.MassemailMasterID GROUP BY dbo.MassEmailDetail.BusinessEmailID "; str = "SELECT DISTINCT COUNT(dbo.MassEmailDetail.BusinessEmailID) AS Expr1, dbo.MassEmailDetail.BusinessEmailID, dbo.MassemailMaster.date, dbo.MassemailMaster.Message, dbo.MassemailMaster.AttachmentURL, dbo.MassemailMaster.MasterEmailSentSubject, dbo.MassemailMaster.Mail_message_FormatName FROM dbo.MassEmailDetail INNER JOIN dbo.MassemailMaster ON dbo.MassEmailDetail.MassemailMasterID = dbo.MassemailMaster.MassemailMasterID GROUP BY dbo.MassEmailDetail.BusinessEmailID, dbo.MassemailMaster.date, dbo.MassemailMaster.Message, dbo.MassemailMaster.AttachmentURL, dbo.MassemailMaster.MasterEmailSentSubject, dbo.MassemailMaster.Mail_message_FormatName"; SqlCommand cmd = new SqlCommand(str, con); SqlDataAdapter da = new SqlDataAdapter(str, con); DataTable dt = new DataTable(); da.Fill(dt); GridView2.DataSource = dt; GridView2.DataBind(); con.Close(); con.Open(); foreach (GridViewRow GR in GridView1.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkSelect"); Label BusinessEmailID = (Label)GR.FindControl("lbl_email"); Label lbl_Message = (Label)GR.FindControl("lbl_Message"); Label lbl_Master_EmailSentSubject = (Label)GR.FindControl("lbl_Master_EmailSentSubject"); if (chk.Checked == true) { Session["lbl_Message"] = lbl_Message.Text; Session["lbl_Master_EmailSentSubject"] = lbl_Master_EmailSentSubject.Text; mail = BusinessEmailID.Text; SendMail(); con.Close(); con.Open(); } } lbl_msg.Text = "Mail Send Successfully"; }
protected void btntoExcel_Click(object sender, EventArgs e) { MyNewTest(); foreach (GridViewRow GR in GridView2.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here TextBox goods_name = (TextBox)GR.FindControl("lbl_ItemName"); TextBox goods_code = (TextBox)GR.FindControl("lbl_ItemCode"); TextBox goods_qty = (TextBox)GR.FindControl("lbl_ItemQty"); TextBox goods_price = (TextBox)GR.FindControl("lbl_ItemPrice"); string g_name = Convert.ToString(goods_name.Text.ToString()); string g_code = Convert.ToString(goods_code.Text.ToString()); string g_qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string g_price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Expoted_Files\\gridview.xls;Extended Properties='Excel 12.0;HDR=Yes'")) { conn.Open(); OleDbCommand cmd = new OleDbCommand("INSERT INTO [Sheet1$] ([name], [code], [qty], [price]) values ('" + g_name + "', '" + g_code + "', '" + g_qty + "', '" + g_price + "')", conn); exp = cmd.ExecuteNonQuery(); } } } if (exp > 0) { Response.Write("<script type='text/javascript'>alert('Excel-ის ფაილის ექსპორტი განხორციელდა წარმატებით C: დისკზე, დირექტორიაში Expoted_Files')</script>"); } }
protected void buttondual_Click(object sender, EventArgs e) { if (buttondual.Text == "Select") { foreach (GridViewRow GR in GridView2.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkParty"); if (GR.RowIndex == 0) { chk.Enabled = false; buttondual.Text = "Go"; } else { chk.Enabled = true; buttondual.Text = "Go"; } } } if (buttondual.Text == "Go") { foreach (GridViewRow GR in GridView2.Rows) { CheckBox chk = (CheckBox)GR.FindControl("chkParty"); if (chk.Checked == true) { Label lbl1 = (Label)GR.FindControl("Label13"); ViewState["lb"] = lbl1.Text; SelectMsgforSendBox(); } } } }
protected void AddWaybilldata_ForShop() { string WaybillNum = WaybillNumber_inputID.Value; // waybill number DateTime wbstartdate = WaybillDate_inputID.SelectedDate; string formatWBdate = "yyyy.MM.dd"; string WaybillDate = wbstartdate.ToString(formatWBdate); // waybill date string WaybillType = WaybillType_inputID.SelectedItem.Value; // transaction type string Pay_MethodType = Pay_Method_InputId.SelectedItem.Value; // Cash - OR Bank Transfer string WaybillBuyerId = BuyerId_inputId.SelectedItem.Value; // client Id string txtpay_value = txt_paid.Text; string Paid_Value = Convert.ToString(txtpay_value.ToString().Replace(",", ".")); // Amount of paid Money if (string.IsNullOrEmpty(WaybillNum)) { Response.Write("<script type='text/javascript'>alert('გთხოვთ მიუთითეთ ზედნადების ნომერი')</script>"); } else if (string.IsNullOrEmpty(WaybillType)) { Response.Write("<script type='text/javascript'>alert('გთხოვთ აირჩიეთ ოპერაციის ტიპი')</script>"); } else if (string.IsNullOrEmpty(WaybillBuyerId)) { Response.Write("<script type='text/javascript'>alert('გთხოვთ აირჩიეთ კლიენტი')</script>"); } else { // WayBill TotalPrice if (GridView2.Rows.Count > 0) { string Sumtotalprice = ((TextBox)GridView2.FooterRow.FindControl("txt_SumOfWaybill") as TextBox).Text; Convert.ToDouble(Sumtotalprice.ToString()); con.Open(); string str = "INSERT INTO tenders_waybills (user_id,waybill_date,expense_type,expense_way,contractor_id,waybill_number,cost,paid) OUTPUT INSERTED.ID VALUES ('" + AuthUsers.strSessionValue.ToString() + "','" + WaybillDate + "','" + WaybillType + "','" + Pay_MethodType + "','" + WaybillBuyerId + "', N'" + WaybillNum + "','" + Sumtotalprice + "', '" + Paid_Value + "')"; SqlCommand strCmd = new SqlCommand(str, con); //Inserted TenderId Int32 newId = (Int32)strCmd.ExecuteScalar(); if (string.IsNullOrEmpty(newId.ToString())) { Response.Write("<script type='text/javascript'>alert('ტენდერის ბაზაში დამატება ვერ მოხერხდა')</script>"); } con.Close(); foreach (GridViewRow GR in GridView2.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here HiddenField goods_id = (HiddenField)GR.FindControl("HiddenField_GoodId"); Label goods_unit = (Label)GR.FindControl("lbl_ItemUnit"); Label goods_qty = (Label)GR.FindControl("lbl_ItemQty"); Label goods_price = (Label)GR.FindControl("lbl_ItemPrice"); int g_id = Convert.ToInt32(goods_id.Value.ToString()); string g_unit = Convert.ToString(goods_unit.Text.ToString()); string g_qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string g_price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); con.Open(); string str3 = "insert into tenders_items (waybill_id, goods_id, unit_name, quantity, price) Values ('" + newId + "', '" + g_id + "', N'" + g_unit + "', '" + g_qty + "', '" + g_price + "')"; SqlCommand strCmd3 = new SqlCommand(str3, con); int count_ins = strCmd3.ExecuteNonQuery(); } con.Close(); } Response.Redirect("nwaybills.aspx"); } else { Response.Write("<script type='text/javascript'>alert('ბაზაში დამატება ვერ მოხერხდა, გთხოვთ შეავსოთ ფასების ცხრილი')</script>"); } } }
protected void Btn_Add_To_DB_clicked(object sender, ImageClickEventArgs e) { DateTime begintime = txt_tndr_date.SelectedDate; // Use time from textbox string format1 = "yyyy.MM.dd"; // Use this format string tenderbegin = begintime.ToString(format1); DateTime endtime = txt_tndr_ends.SelectedDate; // Use time from textbox string format2 = "yyyy.MM.dd"; // Use this format string tenderends = endtime.ToString(format2); string drop = dropdown_suppliers.SelectedItem.Value.ToString(); string price_text = Convert.ToString(txt_tndr_price.Text.ToString().Replace(",", ".")); con.Open(); string str = "insert into tenders (tender_num, contractor_id, tender_date, tender_ends, tender_price, tender_category) Values ('" + txt_tndr_num.Text + "', '" + drop + "', '" + tenderbegin + "', '" + tenderends + "', '" + price_text + "', N'" + txt_tndr_cat.Text + "')"; SqlCommand cmd = new SqlCommand(str, con); cmd.ExecuteNonQuery(); SqlCommand strsql = new SqlCommand("SELECT SCOPE_IDENTITY () As NewID", con); SqlDataReader dr = strsql.ExecuteReader(); dr.Read(); if (!dr.HasRows) { Response.Write("<script type='text/javascript'>alert('ბაზაში დამატება ვერ მოხერხდა')</script>"); } int tenderID = Convert.ToInt32(dr["NewID"]); // Response.Write("<script type='text/javascript'>alert('" + newRowID + "')</script>"); dr.Close(); con.Close(); foreach (GridViewRow GR in GridView1.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here TextBox goods_id = (TextBox)GR.FindControl("txt_TenderId"); TextBox goods_name = (TextBox)GR.FindControl("txt_TenderName"); TextBox goods_unit = (TextBox)GR.FindControl("txt_TenderUnit"); TextBox goods_qty = (TextBox)GR.FindControl("txt_TenderQty"); TextBox goods_price = (TextBox)GR.FindControl("txt_TenderPrice"); TextBox goods_code = (TextBox)GR.FindControl("txt_TenderItemCode"); int id = Convert.ToInt32(goods_id.Text.ToString()); string qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); int transaction_type = 1; Convert.ToInt32(transaction_type.ToString()); con.Open(); string str2 = "insert into tenders_items (tender_id, goods_id, quantity, price, tr_type) Values ('" + tenderID + "', '" + id + "', '" + qty + "', '" + price + "', '" + transaction_type + "')"; SqlCommand cmd2 = new SqlCommand(str2, con); cmd2.ExecuteNonQuery(); con.Close(); } } }
protected void AddTenderdata_ToDB() { // Tender SPA Number string TenderNum = TenderNumber_inputID.Value; // Tender date from DateTime startDate = TenderDateFrom.SelectedDate; string formatDateFrom = "yyyy.MM.dd"; string TenderFrom = startDate.ToString(formatDateFrom); // Tender date to DateTime endDate = TenderDateTo.SelectedDate; string formatDateTo = "yyyy.MM.dd"; string TenderTo = endDate.ToString(formatDateTo); // Tender Category string TenderCategory = TenderCategory_inputId.Value; // Tender ContractorId string TenderSupplierId = Contractor_inputId.SelectedItem.Value; // Waybill Number string var1 = Convert.ToString(DateTime.Now.ToString().Replace(":", "")); string var2 = Convert.ToString(var1.ToString().Replace("/", "")); string waybillDateNow = Convert.ToString(var2.ToString().Replace(" ", "")); if (string.IsNullOrEmpty(TenderNum) || string.IsNullOrEmpty(TenderCategory) || string.IsNullOrEmpty(TenderSupplierId)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "class", "Chk_Textboxes();", true); Response.Write("<script type='text/javascript'>alert('გთხოვთ შეავსეთ ყველა ცარიელი უჯრა')</script>"); } else { // Tender TotalPrice if (GridView2.Rows.Count > 0) { string Sumtotalprice = ((TextBox)GridView2.FooterRow.FindControl("txt_SumOfWaybill") as TextBox).Text; Convert.ToDouble(Sumtotalprice.ToString()); con.Open(); string str = "INSERT INTO tenders (tender_num,contractor_id,tender_date,tender_ends,tender_price,tender_category) OUTPUT INSERTED.ID VALUES (N'" + TenderNum + "','" + TenderSupplierId + "','" + TenderFrom + "','" + TenderTo + "','" + Sumtotalprice + "',N'" + TenderCategory + "')"; SqlCommand strCmd = new SqlCommand(str, con); //Inserted Tenders' Id Int32 newId = (Int32)strCmd.ExecuteScalar(); if (newId == 0 || string.IsNullOrEmpty(newId.ToString())) { Response.Write("<script type='text/javascript'>alert('ტენდერის ბაზაში დამატება ვერ მოხერხდა')</script>"); } con.Close(); //Positive Transaction Type int transaction_type = 1; Convert.ToInt32(transaction_type.ToString()); con.Open(); string str2 = "insert into tenders_waybills (user_id, tender_id, waybill_date, contractor_id, waybill_number) OUTPUT INSERTED.ID Values ('" + AuthUsers.strSessionValue.ToString() + "', '" + newId + "', '" + TenderFrom + "', '" + TenderSupplierId + "', '" + waybillDateNow + "')"; SqlCommand strCmd2 = new SqlCommand(str2, con); //Inserted Waybills' Id Int32 newId2 = (Int32)strCmd2.ExecuteScalar(); if (newId2 == 0 || string.IsNullOrEmpty(newId2.ToString())) { Response.Write("<script type='text/javascript'>alert('ზედნადების ბაზაში დამატება ვერ მოხერხდა, გთხოვთ შეავსოთ ყველა საჭირო მონაცემები')</script>"); } con.Close(); foreach (GridViewRow GR in GridView2.Rows) { if (GR.RowType == DataControlRowType.DataRow) { // You can also find grid view inside controls here HiddenField goods_id = (HiddenField)GR.FindControl("HiddenField_GoodId"); Label goods_unit = (Label)GR.FindControl("lbl_ItemUnit"); Label goods_qty = (Label)GR.FindControl("lbl_ItemQty"); Label goods_price = (Label)GR.FindControl("lbl_ItemPrice"); int g_id = Convert.ToInt32(goods_id.Value.ToString()); string g_unit = Convert.ToString(goods_unit.Text.ToString()); string g_qty = Convert.ToString(goods_qty.Text.ToString().Replace(",", ".")); string g_price = Convert.ToString(goods_price.Text.ToString().Replace(",", ".")); con.Open(); string str3 = "insert into tenders_items (waybill_id, goods_id, unit_name, quantity, price) Values ('" + newId2 + "', '" + g_id + "', N'" + g_unit + "', '" + g_qty + "', '" + g_price + "')"; SqlCommand strCmd3 = new SqlCommand(str3, con); strCmd3.ExecuteNonQuery(); con.Close(); } } } else { Response.Write("<script type='text/javascript'>alert('ბაზაში დამატება ვერ მოხერხდა, გთხოვთ შეავსოთ ფასების ცხრილი')</script>"); } } }
protected void fillgrid() { DataTable dt = new DataTable(); if (txtamount.Text.Length < 0) { txtamount.Text = "0.00"; } if (Convert.ToString(ViewState["data"]) == "") { dt = CreateDatatable(); DataRow Drow = dt.NewRow(); Drow["Overheadname"] = txtovername.Text; Drow["Amount"] = String.Format("{0:n}", Convert.ToDecimal(txtamount.Text)); //Drow["ID"] = 1; dt.Rows.Add(Drow); ViewState["data"] = dt; } else { dt = (DataTable)ViewState["data"]; int flag = 0; foreach (DataRow dr in dt.Rows) { string Overheadname = dr["Overheadname"].ToString(); string Amount = dr["Amount"].ToString(); if (Overheadname == txtovername.Text && Amount == txtamount.Text) { lblmsg.Text = "Record already exist"; flag = 1; break; } } if (flag == 0) { DataRow Drow = dt.NewRow(); Drow["Overheadname"] = txtovername.Text; Drow["Amount"] = String.Format("{0:n}", Convert.ToDecimal(txtamount.Text)); //Drow["ID"] = 1; dt.Rows.Add(Drow); ViewState["data"] = dt; } } decimal d33 = 0; GridView1.DataSource = dt; GridView1.DataBind(); if (GridView1.Rows.Count > 0) { Button6.Visible = true; } foreach (GridViewRow GR in GridView1.Rows) { Label Label159 = (Label)GR.FindControl("Label159"); string d3 = Label159.Text; d33 += Convert.ToDecimal(d3); } lbltotal1.Text = d33.ToString("###,###.##"); lbl1rate.Text = lbltotal1.Text; if (lbl1rate.Text.Length < 0) { lbl1rate.Text = "0.00"; } if (lbl2rate.Text == "") { lblmsg.Text = "Please set your Batch Working Days first."; lbl3rate.Text = ""; //double div = Convert.ToDouble(lbl1rate.Text) / Convert.ToDouble(lbl2rate.Text); //lbl3rate.Text = String.Format("{0:n}", Convert.ToDecimal(div)); } else { double div = Convert.ToDouble(lbl1rate.Text) / Convert.ToDouble(lbl2rate.Text); //lbl3rate.Text = div.ToString("###,###.##"); lbl3rate.Text = String.Format("{0:n}", Convert.ToDecimal(div)); } if (lbl3rate.Text != "") { Button3.Visible = true; Button6.Visible = true; } else { Button6.Visible = false; } }