//internal Inv_BuyCentral LoadByCentralData(string p1, string p2) //{ // try // { // throw new NotImplementedException(); // } // catch (Exception ex) // { // throw new Exception(ex.Message.ToString()); // } //} internal int Insert(Inv_IChallan_Temp _ObjIchalanT) { try { _context.Inv_IChallan_Temp.AddObject(_ObjIchalanT); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
protected void BtnAdd_Click(object sender, EventArgs e) { //string pronductNameandBrand = ddlItemName.SelectedItem.ToString(); //string[] values = pronductNameandBrand.Split(' '); Inv_IChallan_Temp _ObjIchalanT = new Inv_IChallan_Temp(); //if (txtChalanNo.Text == "") //{ // GenarateGinNumber(); //} try { string BarCode = ddlItemName.SelectedValue; Guid userId = ((SessionUser)Session["SessionUser"]).UserId; if (BtnAdd.Text == "Add") { //string BarCode = hdnBarCode.Value.ToString(); //if (BarCode == string.Empty || txtBalanceQty.Text == string.Empty || txtIssueQty.Text == "0") //{ // // lblMessage.Text = "<font color='red'>Sorry! Invalid data. Issue quantity cannot be zero or negative. Please enter correct data</font>"; // ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Sorry! Invalid data. Issue quantity cannot be zero or negative. Please enter correct data')", true); // return; //} if (ddlSubCompany.SelectedItem.Text == "--Select Sub company--") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Sub Company!')", true); return; } if (double.Parse(txtIssueQty.Text) > double.Parse(txtBalanceQty.Text)) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Sorry! There are not enough quantity of selected good to issue. Please issue with less quantity')", true); return; } //var GetDataByIChallan_Tem = iChallanBll.GetDataByIChallan_Tem(txtChalanNo.Text, BarCode).ToList(); var GetDataByIChallan_Tem = iChallanBll.GetDataByIChallan_TemUserWise(userId, BarCode).ToList(); if (GetDataByIChallan_Tem.Count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Item Already Exist In The List')", true); return; } try { _ObjIchalanT.OldCompanyCode = ddlStore.SelectedValue.ToString(); _ObjIchalanT.SeasonID = Convert.ToInt32(ddlSeason.SelectedValue.ToString()); _ObjIchalanT.OrderEId = Convert.ToInt32(ddlOrder.SelectedValue.ToString()); _ObjIchalanT.DeliveryDate = Convert.ToDateTime(txtDate.Text); _ObjIchalanT.ChallanNo = txtChalanNo.Text; _ObjIchalanT.Sub_Company = ddlSubCompany.SelectedItem.Text; _ObjIchalanT.EID = hIdEid.Value; _ObjIchalanT.ProductGroup = Convert.ToInt32(ddlItemGroup.SelectedValue.ToString()); _ObjIchalanT.ProductId = int.Parse(ddlItemName.SelectedValue.ToString());//Convert.ToInt32(txtProductId.Text.Trim()); //purchase.ProductGroup = int.Parse(ddlProductGroup.SelectedValue.ToString()); //purchase.Barcode = buyCentralBll.GetBarcode(int.Parse(purchase.ProductId.ToString())); _ObjIchalanT.BarCode = Convert.ToInt16(_ObjIchalanT.ProductId).ToString(); string pronductNameandBrand = ddlItemName.SelectedItem.ToString(); string[] values = pronductNameandBrand.Split('+'); _ObjIchalanT.ProductName = values[0].ToString(); _ObjIchalanT.UnitName = txtUnit.Text; _ObjIchalanT.BalanceQuanity = Convert.ToDouble(txtBalanceQty.Text); _ObjIchalanT.DeliveryQty = Convert.ToDouble(txtIssueQty.Text); string OCode = ((SessionUser)Session["SessionUser"]).OCode; _ObjIchalanT.EditDate = DateTime.Now; _ObjIchalanT.EditUser = ((SessionUser)Session["SessionUser"]).UserId; _ObjIchalanT.OCode = OCode; iChallanBll.Insert(_ObjIchalanT); #region Comments All Old Code //SerialNo = SerialNo + 1; //purchase.Id = SerialNo; //Hashtable ht = new Hashtable(); //ht.Add("Store_Id", ddlStore.SelectedValue); //ht.Add("SeasonID", ddlSeason.SelectedValue); //ht.Add("OrderEId", ddlOrder.SelectedValue); ////ht.Add("PurchaseDate", txtDate.Text.ToString()); //ht.Add("ProductGroup", ddlItemGroup.SelectedValue); //ht.Add("BarCode", BarCode); //ht.Add("ProductId", ddlItemName.SelectedValue); //ht.Add("ProductName", values[0].ToString()); //ht.Add("UnitName", txtUnit.Text); //ht.Add("Brand", hdnBrand.Value); //ht.Add("StyleSize", hdnStyleSize.Value); //ht.Add("ChallanNo", txtChalanNo.Text); //ht.Add("DeliveryQty", txtIssueQty.Text); ////ht.Add("OrderNo", txtOrderNo.Text); ////ht.Add("TransferDate", txtDate.Text); ////ht.Add("DPT_CODE", ddlDepartment.SelectedValue.ToString()); //ht.Add("EID", hIdEid.Value); //ht.Add("CPU", txtCPU.Text); //ht.Add("ChallanTotal", txtTotalCost.Text); //ht.Add("CurrentCompanyCode", "n/a"); //ht.Add("OldCompanyCode", ddlStore.SelectedValue); //ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode.ToString()); ////ht.Add("OldCompanyCode", "8989"); ////ht.Add("OCode", "8989"); //DataTable dt = iChallanBll.DeliverProduct_Temp(ht); #endregion //grvIssue.DataSource = dt; //grvIssue.DataBind(); BindPurchaseGrid(); ClearForm(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Issue information has been added temporarily. Please post.')", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } } else { if (BtnAdd.Text == "Update") { double qty = Convert.ToDouble(txtIssueQty.Text); var mn = iChallanBll.Update_IChalanTemp(userId, BarCode, qty); if (mn == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update Successfully')", true); BindPurchaseGrid(); ClearForm(); BtnAdd.Text = "Add"; return; } else { } } } BindPurchaseGrid(); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }