public JsonResult Delete_PO(int PoId) { string _Del = null; try { KeystoneProject.Buisness_Logic.Pharmacy.BL_PurchaseOrder objdb = new BL_PurchaseOrder(); PurchaseOrder objSG = new Models.Pharmacy.PurchaseOrder(); int DependaincyName = objdb.DeletePurchaseOrder(PoId); if (DependaincyName > 0) { _Del = "Purchase Order Deleted Successfully !"; } else { _Del = "Purchase Order Can not be Deleted !"; } } catch (Exception ex) { throw ex; } return(new JsonResult { Data = _Del, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult AjaxMethod_CheckProduct(string productNameID1, FormCollection fc) { KeystoneProject.Buisness_Logic.Pharmacy.BL_PurchaseOrder BL_obj = new BL_PurchaseOrder(); KeystoneProject.Models.Pharmacy.PurchaseOrder obj = new PurchaseOrder(); List <string> searchList = new List <string>(); try { DataTable dt = new DataTable(); DataSet ds = BL_obj.Bind_Newproductdetail("%", productNameID1); if (ds.Tables[0].Rows.Count > 0) { dt = BL_obj.Bind_PackQtyRate(Convert.ToInt16(ds.Tables[0].Rows[0]["ProductID"].ToString())); obj.manufacturerName1 = dt.Rows[0]["MfrName"].ToString(); obj.packing1 = dt.Rows[0]["Packing"].ToString(); obj.minLevel1 = dt.Rows[0]["MinQtyLevel"].ToString(); obj.maxLevel1 = dt.Rows[0]["MaxQtyLevel"].ToString(); obj.productNameID1 = dt.Rows[0]["ProductID"].ToString(); searchList.Add(obj.manufacturerName1); searchList.Add(obj.packing1); searchList.Add(obj.minLevel1); searchList.Add(obj.maxLevel1); searchList.Add(obj.productNameID1); } return(Json(searchList)); } catch (Exception ex) { return(Json(searchList)); } }
//Item Grid Bind #region [Item Category Grid Bind] private void BindItemGrid() { try { EWA_PurchaseOrder objEWA = new EWA_PurchaseOrder(); BL_PurchaseOrder objBL = new BL_PurchaseOrder(); objEWA.SupplierId = ddlSupplier.SelectedValue; objEWA.OrgId = orgId; DataSet ds = objBL.BindItemGrid_BL(objEWA); if (ds.Tables[0].Rows.Count == 0 || ds == null) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); GrdItem.DataSource = ds; GrdItem.DataBind(); int columncount = GrdItem.Rows[0].Cells.Count; GrdItem.Rows[0].Cells.Clear(); GrdItem.Rows[0].Cells.Add(new TableCell()); GrdItem.Rows[0].Cells[0].ColumnSpan = columncount; GrdItem.Rows[0].Cells[0].Text = "No Records Found"; } else { GrdItem.DataSource = ds; GrdItem.DataBind(); ItemName1.Text = ds.Tables[0].Rows[0]["ItemName"].ToString(); Category1.Text = ds.Tables[0].Rows[0]["CategoryName"].ToString(); Suppliername1.Text = ddlSupplier.SelectedItem.ToString(); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
private void BindSupplier() { try { EWA_PurchaseOrder objEWA = new EWA_PurchaseOrder(); BL_PurchaseOrder ObjBL = new BL_PurchaseOrder(); objEWA.OrgId = orgId; DataSet dsSupplier = ObjBL.BindSupplier_BL(objEWA); ddlSupplier.DataSource = dsSupplier; ddlSupplier.DataTextField = "SupplierName"; ddlSupplier.DataValueField = "SupplierId"; ddlSupplier.DataBind(); ddlSupplier.Items.Insert(0, "Select"); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
public ActionResult AjaxMethod_PurType(string purchaseType) { KeystoneProject.Buisness_Logic.Pharmacy.BL_PurchaseOrder BL_obj = new BL_PurchaseOrder(); KeystoneProject.Models.Pharmacy.PurchaseOrder obj = new PurchaseOrder(); List <PurchaseOrder> searchList = new List <PurchaseOrder>(); DataTable td = new DataTable(); DataSet ds = BL_obj.Bind_PurTypeMode(purchaseType); foreach (DataRow dr in ds.Tables[0].Rows) { searchList.Add( new PurchaseOrder { purchaseTypeMode = Convert.ToString(dr["AccountName"]), }); } return(new JsonResult { Data = searchList, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void GetPOCode() { try { EWA_PurchaseOrder objEWA = new EWA_PurchaseOrder(); BL_PurchaseOrder objBL = new BL_PurchaseOrder(); //Send it from Session objEWA.OrgId = orgId; DataSet POCodeds = objBL.GetPOCode_BL(objEWA); string POCode = POCodeds.Tables[0].Rows[0][0].ToString(); String POrdCode = "PO/" + orgId + "/" + POCode; // lblPOCode.Text = objEWA.OrgId + StaffId; ViewState["POCode"] = POrdCode; Session["POCode"] = POrdCode; txtPOCode.Text = ViewState["POCode"].ToString(); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
public ActionResult AjaxMethod_SUPP(string supplierName) { KeystoneProject.Buisness_Logic.Pharmacy.BL_PurchaseOrder BL_obj = new BL_PurchaseOrder(); KeystoneProject.Models.Pharmacy.PurchaseOrder obj = new PurchaseOrder(); List <PurchaseOrder> searchList = new List <PurchaseOrder>(); DataTable td = new DataTable(); DataSet ds = BL_obj.Bind_supplier(supplierName, "%"); td = BL_obj.Getaddress(Convert.ToInt16(ds.Tables[0].Rows[0]["ProductSupplierID"].ToString())); foreach (DataRow dr in td.Rows) { searchList.Add( new PurchaseOrder { address = Convert.ToString(dr["Address"]), }); } return(new JsonResult { Data = searchList, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
//Perform Action #region [Perform Action] private void Action(string strAction) { try { EWA_PurchaseOrder objEWA = new EWA_PurchaseOrder(); BL_PurchaseOrder objBL = new BL_PurchaseOrder(); objEWA.Action = strAction; if (strAction == "Update" || strAction == "Delete") { objEWA.POId = Convert.ToInt32(ViewState["POId"].ToString()); } objEWA.PODate = txtPODate.Text; objEWA.POCode = txtPOCode.Text.Trim(); objEWA.SupplierId = ddlSupplier.SelectedValue; objEWA.GrandTotal = ViewState["GrandTotal"].ToString(); objEWA.PaymentMode = ddlPaymentMode.SelectedItem.ToString(); objEWA.DeliveryMode = ddlDeliveryMode.SelectedItem.ToString(); objEWA.Remark = txtRemark.Text.Trim(); objEWA.OrgId = orgId; objEWA.UserId = Session["UserCode"].ToString(); objEWA.IsActive = "True"; //int count = GrdItem.Rows.Count; //DataTable dt = new DataTable(); //foreach (GridViewRow gvrow in GrdItem.Rows) //{ // CheckBox chk = (CheckBox)gvrow.FindControl("chkBxSelect"); // if (chk != null && chk.Checked) // { // if (ViewState["POItem"] == null) // { // dt.Columns.Add("ItemId"); // dt.Columns.Add("Quantity"); // dt.Columns.Add("Rate"); // DataRow rw = dt.NewRow(); // // rw["SupplierId"] = ddlPartyName.SelectedItem.Value.ToString(); // rw["ItemId"] = GrdItem.DataKeys[gvrow.RowIndex].Values["ItemId"].ToString(); // rw["Quantity"] = GrdItem.DataKeys[gvrow.RowIndex].Values["Quantity"].ToString(); // rw["Rate"] = GrdItem.DataKeys[gvrow.RowIndex].Values["Rate"].ToString(); // dt.Rows.Add(rw); // ViewState["POItems"] = dt as DataTable; // } // else // { // int cnt = 0; // dt = ViewState["POItems"] as DataTable; // foreach (DataRow drow in dt.Rows) // { // if (!chk.Checked) // { // cnt = 1; // } // } // if (cnt == 0) // { // DataRow rw = dt.NewRow(); // rw["ItemId"] = GrdItem.DataKeys[gvrow.RowIndex].Values["ItemId"].ToString(); // rw["Quantity"] = GrdItem.DataKeys[gvrow.RowIndex].Values["Quantity"].ToString(); // rw["Rate"] = GrdItem.DataKeys[gvrow.RowIndex].Values["Rate"].ToString(); // dt.Rows.Add(rw); // ViewState["POItem"] = dt as DataTable; // } // } // } // } DataTable dt = new DataTable(); int count = 0; if (GrdItem.Rows[0].Cells[2].Text == "" || GrdItem.Rows[0].Cells[2].Text == " ") { msgBox.ShowMessage("Please Select Supplier Items !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } foreach (GridViewRow rw in GrdItem.Rows) { CheckBox chkItem = new CheckBox(); chkItem = rw.Cells[0].FindControl("chkBxSelect") as CheckBox; if (chkItem.Checked) { TextBox txtQty = new TextBox(); TextBox txtRate = new TextBox(); Label lblTotalAmt = new Label(); txtQty = rw.Cells[5].FindControl("txtQty") as TextBox; txtRate = rw.Cells[6].FindControl("txtRate") as TextBox; lblTotalAmt = rw.Cells[7].FindControl("lblTotalAmount") as Label; double chkout = 0; if (txtQty.Text == "") { msgBox.ShowMessage("Please Enter Product Quantity !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } else if (txtRate.Text == "") { msgBox.ShowMessage("Please Enter Product Rate !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } else if (double.TryParse(txtQty.Text, out chkout) == false) { msgBox.ShowMessage("Please Enter Valid Quantity !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } else if (double.TryParse(txtRate.Text, out chkout) == false) { msgBox.ShowMessage("Please Enter Valid Rate !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } if (ViewState["POItem"] != null) { dt = ViewState["POItem"] as DataTable; for (int i = 0; i < dt.Rows.Count; i++) { if (rw.Cells[2].Text == dt.Rows[i][2].ToString()) { msgBox.ShowMessage("This Item is Allready Exist !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } } dt.Rows.Add(0, GrdItem.DataKeys[rw.RowIndex].Value, txtQty.Text, txtRate.Text, lblTotalAmt.Text); // dt.Rows.Add(0, GrdItem.DataKeys[rw.RowIndex].Value, rw.Cells[2].Text, rw.Cells[3].Text, rw.Cells[4].Text, txtQty.Text, txtRate.Text); } else { dt.Columns.Add("POId"); dt.Columns.Add("ItemId"); //dt.Columns.Add("ItemName"); //dt.Columns.Add("Category"); // dt.Columns.Add("Unit"); dt.Columns.Add("Qty"); dt.Columns.Add("Rate"); dt.Columns.Add("TotalAmt"); //dt.Rows.Add(0, GrdItem.DataKeys[rw.RowIndex].Value, rw.Cells[2].Text, rw.Cells[3].Text,rw.Cells[4].Text, txtQty.Text, txtRate.Text); dt.Rows.Add(0, GrdItem.DataKeys[rw.RowIndex].Value, txtQty.Text, txtRate.Text, lblTotalAmt.Text); ViewState["POItem"] = dt; //ItemName1.Text = GrdItem.Rows[0].Cells[1].ToString(); //Category1.Text = GrdItem.Rows[0].Cells[2].ToString(); qty1.Text = txtQty.Text; Rate1.Text = txtRate.Text; Tamt1.Text = lblTotalAmt.Text; } count = count + 1; } } if (count == 0) { msgBox.ShowMessage("Please Select Items !!!", "Information", UserControls.MessageBox.MessageStyle.Information); return; } else { //GrdSelectedItems.DataSource = dt; // GrdSelectedItems.DataBind(); //if (ViewState["DSItems"] != null) //{ // DataSet dsItemsOrg = ViewState["DSItems"] as DataSet; // GrdItem.DataSource = dsItemsOrg; // GrdItem.DataBind(); //} //CalculateAmt(); //Calculation(); // GrdTax.Enabled = true; } dt = ViewState["POItem"] as DataTable; DataSet ds = objBL.POAction_BL(objEWA, dt); if (ds.Tables[0].Rows.Count > 0) { if (strAction == "Save") { GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); Suppliername1.Text = ds.Tables[0].Rows[0]["SupplierName"].ToString(); ItemName1.Text = ds.Tables[0].Rows[0]["PODate"].ToString(); Tamt1.Text = ds.Tables[0].Rows[0]["GrandTotal"].ToString(); //lblPOCode.Text = ds.Tables[0].Rows[0]["POCode"].ToString(); msgBox.ShowMessage("Record Saved Successfully !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); } else if (strAction == "Update") { msgBox.ShowMessage("Record Updated Successfully !!!", "Updated", UserControls.MessageBox.MessageStyle.Successfull); } else if (strAction == "Delete") { msgBox.ShowMessage("Record Deleted Successfully !!!", "Deleted", UserControls.MessageBox.MessageStyle.Successfull); } } else { if (strAction == "Save") { msgBox.ShowMessage("Unable to Save !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } else if (strAction == "Update") { msgBox.ShowMessage("Unable to Update !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } else if (strAction == "Delete") { msgBox.ShowMessage("Unable to Delete !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Save Data #region SaveData protected void btnSave_Click(object sender, EventArgs e) { EWA_PurchaseOrder objEWA = new EWA_PurchaseOrder(); BL_PurchaseOrder objBL = new BL_PurchaseOrder(); try { lock (this) { //ViewState["DocumentId"] = 0; int chk = 0;//= CheckData(); if (chk > 0) { msgBox.ShowMessage("Record Allready Exist !!!", "Information", UserControls.MessageBox.MessageStyle.Information); } else { Action("Save"); // int count = GrdItem.Rows.Count; // string[] Itemstock = new string[count]; // int i = 0; // foreach (GridViewRow gvrow in GrdItem.Rows) // { // TextBox txtQty = new TextBox(); // txtQty = gvrow.Cells[5].FindControl("txtQty") as TextBox; // CheckBox chk1 = (CheckBox)gvrow.FindControl("chkBxSelect"); // if (chk1 != null && chk1.Checked) // { // Itemstock[i] = GrdItem.DataKeys[gvrow.RowIndex].Values["ItemName"].ToString(); // // TextBox txtValueMain = GrdItem.Cells[1].FindControl("txtValue") as TextBox; // itemid = db.getDb_Value(" SELECT tblItem.ItemId FROM tblItem INNER JOIN tblItemSupplier ON tblItem.ItemId = tblItemSupplier.ItemId WHERE tblItem.OrgId = '" + orgId.ToString() + "' AND tblItem.ItemName = '" + Itemstock[i] + "' AND tblItemSupplier.SupplierId = '" + ddlSupplier.Text + "'"); // //for stock maintain // itemname12 = db.getDbstatus_Value("SELECT tblItem.ItemName FROM tblItem INNER JOIN tblItemSupplier ON tblItem.ItemId = tblItemSupplier.ItemId WHERE (tblItem.OrgId = '" + orgId.ToString() + "') AND (tblItem.ItemName = '" + Itemstock[i] + "') AND (tblItemSupplier.SupplierId = '" + ddlSupplier.Text + "')"); // stock = db.getDb_Value("select Stock from tblItem where OrgId='" + orgId.ToString() + "' and ItemName='" + itemname12 + "'"); // float upstock = stock + Convert.ToInt32(txtQty.Text); // db.cnopen(); // // db.insert("insert into tblItem (Stock,ItemName) values ('" + upstock + "','" + itemname12 + "' )"); // db.insert("update tblItem set Stock='" + upstock + "' where OrgId='" + orgId.ToString() + "' and ItemName='" + Itemstock[i] + "'"); // db.cnclose(); // i++; // } //} //BindSupplierGrid(); // btnNew.Enabled = false; btnSave.Enabled = false; btnPrint.Enabled = true; clear(); //GrdPurchaseOrder.DataSourceID = "SqlDataSource1"; GrdPurchaseOrder.DataBind(); GetPOCode(); } } } catch (Exception exp) { // GeneralErr(exp.Message.ToString()); } }