public void r101Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (instance.OrderHedID != null) { int i = (int)SqlText.ExecuteScalar("Select isnull(Count(OrderDtlID),0) from OrderDtl Where OrderHedID=@OrderHedID", instance.OrderHedID); if (i > 0) { instance.IsOrderLinesCreated = true; } else { instance.IsOrderLinesCreated = false; } } if (instance.OrderDate != null) { instance.TargetReportingDate = Convert.ToDateTime(instance.OrderDate).AddDays(7); } if (instance.Owner == "YS,LAI") { instance.Owner = "YS.LAI"; } //if (instance[OrderHeaderDataField.UnPaidInvoices].Modified || // instance[OrderHeaderDataField.CreditLimit].Modified ) //{ // //Result.ShowModal("CustomerStatement", "editForm1", "Select", null); // if(instance.UnPaidInvoices > instance.CreditLimit) // { // instance.Exception = true; // instance.ExceptionDtl = "#Credit Limit Exceeded"; // } //} //if (instance[OrderHeaderDataField.TermsExceed].Modified) //{ // //Result.ShowModal("CustomerStatement", "editForm1", "Select", null); // if(instance.TermsExceed !=null && Convert.ToBoolean(instance.TermsExceed)) // { // instance.Exception = true; // instance.ExceptionDtl += " #Terms Exceeded"; // } //} //string filePath = @"D:\OldPC\Epicor\Epicor Docs\ConsultantRoadmap.pdf"; ////FileInfo file = new FileInfo(filePath); //WebClient test = new WebClient(); //byte[] data= test.DownloadData(filePath); //instance.ContentType = "application/pdf"; //instance.FileName = "ConsultantRoadmap.pdf"; //instance.Length = 489818; //UpdateFieldValue("Attachment", filePath); }
public void r106Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. //int i = (int)SqlText.ExecuteScalar("Select isnull(Count(OrderDtlID),0) from OrderDtl Where OrderHedID=@OrderHedID", instance.OrderHedID); //if (i > 0) //{ // NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Static"); // NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Static"); //} //else //{ // //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Auto"); // //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Auto"); //} }
public void r110Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (!string.IsNullOrEmpty(instance.Promotion)) { string[] strArr = instance.Promotion.Split(','); if (strArr.Count() > 1) { if (strArr.Any(w => w == "1")) { PreventDefault(); Result.ShowAlert("Not Valid Combination, Clear Promotion \"None\" Checkbox."); } } } }
public void r100Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. string CompQry = string.Format("select isnull(Count(a.CompanyName),0) from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompCnt = (int)SqlText.ExecuteScalar(CompQry); if (CompCnt == 1) { string GetCompQry = string.Format("select a.CompanyID,a.CompanyName from Company a inner join UsersCompany b on a.CompanyID=b.CompanyID inner join Users c on b.UserID=c.UserID Where c.UserName='******'", UserName); var CompInfo = SqlText.Execute(GetCompQry); if (CompInfo != null) { instance.CompanyID = (int)CompInfo[0]; instance.CompanyName = (string)CompInfo[1]; } } instance.OrderDate = DateTime.Now; instance.ReqShipDate = DateTime.Now; instance.TargetReportingDate = DateTime.Now.AddDays(7); instance.BulkOrder = false; instance.OrderType = "N"; instance.OrderStatusID = 1; instance.OrderStatusName = "Open"; //instance.PromotionID = 1; //instance.PromotionTitle = "None"; if (UserIsInRole("SalesPerson")) { instance.Owner = UserName.ToUpper(); if (UserName == "YS.LAI") { instance.CurUser = "******"; } else { instance.CurUser = UserName.ToUpper(); } } instance.Creator = UserName; instance.CreatedOn = DateTime.Now; }
public void r108Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (Arguments.Trigger.ToLower() == "orderdtl") { decimal total = (decimal)SqlText.ExecuteScalar("select isnull(Sum(SellingPrice * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); decimal proposedTotal = (decimal)SqlText.ExecuteScalar("select isnull(Sum(IIF(ProposedSellingPrice is null, SellingPrice,ProposedSellingPrice) * OrderQty),0) From OrderDtl Where OrderHedID=@OrderHedID ", instance.OrderHedID); instance.TotalAmount = proposedTotal > 0?proposedTotal: total; string totalAmount = instance.TotalAmount.ToString(); int i = SqlText.ExecuteNonQuery("Update OrderHed Set TotalAmount=@totalAmount Where OrderHedID=@OrderHedID", instance.TotalAmount, instance.OrderHedID); } }
public void r102Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. //ActionArgs test = Arguments; //HttpContext http = Context; //http.Items["PageRequest_Current"]).Controller //http.Items["PageRequest_Current"]; Finsoft.Data.PageRequest page = (Finsoft.Data.PageRequest)Context.Items["PageRequest_Current"]; string viewName = page.View; if (page.View == "editForm1") { if (instance.CustSysRowID != null) { var custInfo = SqlText.Execute("select * from vwCustomer where SysRowID=@CustSysRowID", new { CustSysRowID = instance.CustSysRowID }); if (custInfo != null) { instance.CAddress1 = custInfo[5].ToString(); instance.CAddress2 = custInfo[6].ToString(); instance.CAddress3 = custInfo[7].ToString(); instance.CCity = custInfo[8].ToString(); instance.CState = custInfo[9].ToString(); instance.CZip = custInfo[10].ToString(); instance.CCountry = custInfo[11].ToString(); instance.CreditLimit = Convert.ToDecimal(custInfo[14]); instance.Balance = Convert.ToDecimal(custInfo[13]); instance.UnPaidInvoices = Convert.ToDecimal(custInfo[15]); instance.OutStandingOrders = Convert.ToDecimal(custInfo[16]); instance.UnPostedInvoices = Convert.ToDecimal(custInfo[17]); instance.AgeCurr = Convert.ToDecimal(custInfo[18]); instance.Age30 = Convert.ToDecimal(custInfo[19]); instance.Age60 = Convert.ToDecimal(custInfo[20]); instance.Age90 = Convert.ToDecimal(custInfo[21]); instance.Age120 = Convert.ToDecimal(custInfo[22]); instance.Age150 = Convert.ToDecimal(custInfo[23]); instance.TermsExceed = Convert.ToBoolean(custInfo[24]); instance.PhoneNum = custInfo[26].ToString(); instance.FaxNum = custInfo[27].ToString(); } } if (instance.ShipToSysRowID != null) { var shipInfo = SqlText.Execute("select * from vwShipTo where SysRowID=@ShipToSysRowID ", new { ShipToSysRowID = instance.ShipToSysRowID }); if (shipInfo != null) { instance.SAddress1 = shipInfo[6].ToString(); instance.SAddress2 = shipInfo[7].ToString(); instance.SAddress3 = shipInfo[8].ToString(); instance.SCity = shipInfo[9].ToString(); instance.SState = shipInfo[10].ToString(); instance.SZip = shipInfo[11].ToString(); instance.SCountry = shipInfo[12].ToString(); instance.SPhoneNum = shipInfo[14].ToString(); instance.SFaxNum = shipInfo[15].ToString(); } } int i = (int)SqlText.ExecuteScalar("Select isnull(Count(OrderDtlID),0) from OrderDtl Where OrderHedID=@OrderHedID", instance.OrderHedID); if (i > 0) { //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Static"); //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Static"); instance.IsOrderLinesCreated = true; } else { //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("CustSysRowID").SetTextMode("Auto"); //NodeSet().SelectViews("grid1", "editForm1").SelectDataFields("ShipToSysRowID").SetTextMode("Auto"); instance.IsOrderLinesCreated = false; } if (UserIsInRole("SalesPerson")) { if (UserName == "YS.LAI") { instance.CurUser = "******"; } else { instance.CurUser = UserName.ToUpper(); } } } }
public void r109Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. //Result.NavigateUrl = String.Format( // "~/Pages/CustomerReport.html?CustId={0}&_controller=CustomerReport" + // "&_commandName=Select&_commandArgument=SSRS", // "C1000034"); try { //if (instance.OrderHedID==null) //{ // Result.ShowAlert("Please Select Order!"); //} if (string.IsNullOrEmpty(instance.CompanyName)) { Result.ShowAlert("Company is Empty!"); } else if (string.IsNullOrEmpty(instance.CustID)) { Result.ShowAlert("Customer is Empty!"); } else { string custid = string.Format("{0},{1}", instance.CustID, instance.CustID); Result.NavigateUrl = string.Format("~/CustomReport.ashx?Company={0}&CustId={1}&FileName={2}", instance.CompanyName, custid, instance.CustID); } //string dt = DateTime.Now.ToString("yyyy-MM-dd"); //string fileLoc = string.Format(@"D:\OldPC\Epicor\Customers Docs\Lube World\Git\{0}.pdf", instance.CustID); //ServerReportExecute report = new ServerReportExecute(); //report.userName = userName; //report.passWord = passWord; //report.domainName = domainName; //report.reportPath = ""; //report.url = reportUrl; //report.file = fileLoc; //ArrayList arrLstDefaultParam = new ArrayList(); //arrLstDefaultParam.Add(CreateReportParameter("Company", instance.CompanyName)); //arrLstDefaultParam.Add(CreateReportParameter("CustId", custid)); //arrLstDefaultParam.Add(CreateReportParameter("SalesRepCode", null)); //arrLstDefaultParam.Add(CreateReportParameter("GroupCode", null)); //arrLstDefaultParam.Add(CreateReportParameter("CutOffDate", dt)); //report.ReportParams = arrLstDefaultParam; //byte[] reportData = report.PrintReport(); //var reportHandler = ((CustomReport)(ApplicationServices.CreateInstance("Finsoft.Handlers.CustomReport"))); //creport.ReportData = reportData; //creport.ProcessRequest(this.Context); //reportHandler.ProcessRequest(HttpContext.Current); //StringBuilder sb = new StringBuilder(); //sb.Append("<script type = 'text/javascript'>"); //sb.Append("window.open('"); //sb.Append(url); //sb.Append("');"); //sb.Append("</script>"); //this.Context.page //Page.ClientScript.RegisterStartupScript(GetType(), "Redirect", string.Format("window.location.replace(\'{0}?_link={1}\');", permalink[0], HttpUtility.UrlEncode(link)), true); //this.Page.ClientScript.RegisterStartupScript(this.GetType(), // "script", sb.ToString()); //this.Context.Response.Redirect(string.Format("~/CustomReport.ashx?Company={0}&CustId={1}", instance.CompanyName,custid), false); //HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.ContentType = "application/pdf"; //HttpContext.Current.Response.AddHeader("Content-Length", reportData.Length.ToString()); //AppendDownloadTokenCookie(); //var fileName = "Filename.pdf"; //HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", fileName)); //HttpContext.Current.Response.OutputStream.Write(reportData, 0, reportData.Length); //FileInfo file = new FileInfo(filePath); //Context.Response.Clear(); //Context.Response.ContentType = "application/pdf"; ////Context.Response.AddHeader("Content-Disposition", //// String.Format("attachment;filename={0}.pdf", instance.CustID)); ////byte[] reportData = //// File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg"); //Context.Response.AddHeader("Content-Length", reportData.Length.ToString()); ////Context.Response.OutputStream.Write(reportData, 0, reportData.Length); //Context.Response.BinaryWrite(reportData); //var cache = Context.Response.Cache; //cache.SetCacheability(HttpCacheability.Public); //cache.SetOmitVaryStar(true); //cache.SetExpires(DateTime.Now.AddDays(365)); //cache.SetValidUntilExpires(true); //cache.SetLastModifiedFromFileDependencies(); //Context.Response.ContentType = "application/pdf"; //Context.Response.AddHeader("Content-Length", Convert.ToString(reportData.Length)); //Context.Response.AddHeader("File-Name", "Test"); //Context.Response.BinaryWrite(reportData); //Context.Response.OutputStream.Flush(); } catch (Exception ex) { } }
public void r105Implementation(OrderHeaderModel instance) { // This is the placeholder for method implementation. if (instance.OrderHedID != null) { if (instance.OrderDate != null) { instance.TargetReportingDate = Convert.ToDateTime(instance.OrderDate).AddDays(7); } //Atleast One OrderDtl Line should be there else dont submit int LnCnt = (int)SqlText.ExecuteScalar("Select Count(OrderdtlID) from OrderDtl Where OrderHedID=@OrderHedID" , instance.OrderHedID); if (LnCnt <= 0) { Result.ShowAlert("Requrie minimum one OrderDtl Line to Submit for Approval."); return; } //OrderQty should match with Sum(OrderRelQty) else dont Submit int UnMatchQtyCnt = (int)SqlText.ExecuteScalar("Select Count(UnMatchQty) as UnMatchQtyCnt from ( select OrderDtlID,a.OrderQty,isnull((Select Sum(x.OrderRelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0) as TotalRelQty,(a.OrderQty - isnull((Select Sum(x.OrderRelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0)) as UnMatchQty from OrderDtl a where a.OrderHedID=@OrderHedID ) as Y Where Y.UnMatchQty <> 0 " , instance.OrderHedID); if (UnMatchQtyCnt > 0) { Result.ShowAlert("OrderQty is not matching OrderRel Qty."); return; } //OrderFOCQty should match with Sum(OrderRelFOCQty) else dont Submit int UnMatchFOCQtyCnt = (int)SqlText.ExecuteScalar("Select Count(UnMatchQty) as UnMatchQtyCnt from ( select OrderDtlID,a.Focqty,isnull((Select Sum(x.FocrelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0) as TotalRelQty,(a.Focqty - isnull((Select Sum(x.FocrelQty) from OrderRel x Where x.OrderDtlID=a.OrderDtlID),0)) as UnMatchQty from OrderDtl a where a.OrderHedID=@OrderHedID ) as Y Where Y.UnMatchQty <> 0 " , instance.OrderHedID); if (UnMatchFOCQtyCnt > 0) { Result.ShowAlert("Order FOCQty is not matching OrderRel FOCQty."); return; } instance.Exception = false; instance.ExceptionDtl = string.Empty; //1. Credit Limit Exception int creditEx = (int)SqlText.ExecuteScalar("select isnull(Case When a.UnPaidInvoices > a.CreditLimit2 Then 1 Else 0 End,0) From vwCustomer a inner join OrderHed b on a.SysRowID=b.CustSysRowID Where b.OrderHedID=@OrderHedID" , instance.OrderHedID); if (creditEx > 0) { instance.Exception = true; instance.ExceptionDtl = "CreditLimit"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, creditEx); } //2. Terms Exception int termsEx = (int)SqlText.ExecuteScalar("select isnull(Case When a.TermsExceed=1 Then 2 Else 0 End,0) From vwCustomer a inner join OrderHed b on a.SysRowID=b.CustSysRowID Where b.OrderHedID=@OrderHedID" , instance.OrderHedID); if (termsEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl)?"Terms":", Terms"; //int i=SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, termsEx); } //3. BasePrice Exception int basePriceEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 3 Else 0 End,0) from OrderDtl where ProposedBasePrice < BasePrice and OrderHedID=@OrderHedID" , instance.OrderHedID); if (basePriceEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "BasePrice" : ", BasePrice"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, basePriceEx); } //4. SellingPrice Exception int sellingPriceEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 4 Else 0 End,0) from OrderDtl where ProposedSellingPrice < SellingPrice and OrderHedID=@OrderHedID" , instance.OrderHedID); if (sellingPriceEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "SellingPrice" : ", SellingPrice"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, sellingPriceEx); } //5. FOC Qty Exception int focQtyEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 5 Else 0 End,0) from OrderDtl where FOCQty>0 and OrderHedID=@OrderHedID" , instance.OrderHedID); if (focQtyEx > 0) { instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "FOCQty" : ", FOCQty"; //int i = SqlText.ExecuteNonQuery("Insert into OrderException values (@OrderHedID,@ExCodeID)", instance.OrderHedID, sellingPriceEx); } //6. FOC Part Item Exception int focPartItemEx = (int)SqlText.ExecuteScalar("select isnull(Case When Count(OrderDtlID)>0 Then 6 Else 0 End,0) from OrderDtl where (BasePrice<=1 Or SellingPrice <=1) and OrderHedID=@OrderHedID" , instance.OrderHedID); if (focPartItemEx > 0) { //instance.Exception = true; instance.ExceptionDtl += string.IsNullOrEmpty(instance.ExceptionDtl) ? "FOCPartItem" : ", FOCPartItem"; } //Approval //2 - Waiting For Price Change , 5 - Waiting For Lv1 Approval int ordStatus = (basePriceEx > 0 || sellingPriceEx > 0 || focQtyEx > 0 || focPartItemEx > 0) ? 2 : 5; string comm = (basePriceEx > 0 || sellingPriceEx > 0 || focQtyEx > 0 || focPartItemEx > 0) ? "Submitted For Price Change" : "Submitted For Approval"; SqlText.ExecuteNonQuery("Update OrderHed Set Exception=@Exception,ExceptionDtl=@ExceptionDtl,OrderStatusID=@OrderStatusID Where OrderHedID=@OrderHedID ", new { instance.Exception, instance.ExceptionDtl, @OrderHedID = instance.OrderHedID, @OrderStatusID = ordStatus }); SqlText.ExecuteNonQuery( "Insert into OrderStatusLog (OrderHedID,UserID,[Comment],[RejectReason],[OtherRemarks],[TranDate]) Values " + "(@OrderHedID,@UserID,@Comment,@RejectReason,@OtherRemarks,@TranDate) " , new { @OrderHedID = instance.OrderHedID, @UserID = UserId, @Comment = comm, @RejectReason = "", @OtherRemarks = "", @TranDate = DateTime.Now }); Result.ShowAlert("OrderNo : {0} {1}", instance.OrderHedID, comm); } else { Result.ShowAlert("Please Select Row!"); } Result.Refresh(); }