protected void LoadProject() { int totalRowsCount = 0; AspNetPager1.PageSize = 10; StringBuilder sbWhere = new StringBuilder(); string anyCondition = txtAnyCondition.Text.Trim(); if (!string.IsNullOrEmpty(anyCondition)) { sbWhere.Append(anyCondition); } DataTable dtProject = prjDal.GetProjectForEmployeeHome(Convert.ToString(EmployeeID ?? string.Empty), sbWhere.ToString(), AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRowsCount); if (dtProject != null && dtProject.Rows.Count > 0) { StringBuilder sbPrjId = new StringBuilder(); dtProject.AsEnumerable().Select(item => (string)item["prjID"]).ToList().ForEach(item => sbPrjId.AppendFormat("'{0}',", item)); projectIdNeed = sbPrjId.ToString().TrimEnd(','); lstTcje = new TransactionDetailsBLL().GetModelList(" AND employeeId = '" + Convert.ToString(EmployeeID ?? string.Empty) + "' AND TRANSACTIONTYPE = 7 AND PROJECTID IN (" + projectIdNeed + ") "); lstPrjProportion = new ProjectProportionBLL().GetModelList(" projectId IN (" + projectIdNeed + ")"); } empProportion = epBll.GetModelList(" AND EMPLOYEEID = '" + Convert.ToString(EmployeeID ?? string.Empty) + "'").FirstOrDefault(); if (string.IsNullOrEmpty(sbWhere.ToString())) { lblFinishedTaskCount.Text = string.Format("{0}", totalRowsCount); } AspNetPager1.RecordCount = totalRowsCount; gvProject.DataSource = dtProject; gvProject.DataBind(); gvProject.Columns[1].Visible = IsExternal; }
private string GetEmployeeAccount(HttpContext context) { StringBuilder sbJsonResult = new StringBuilder(); string employeeID = context.Request.Params["employeeID"]; EmployeeAccount empAcct = empAcctBll.GetModelList(" employeeID = '" + employeeID + "'").FirstOrDefault(); TransactionDetailsBLL transactionDetailsBll = new TransactionDetailsBLL(); //账户余额 decimal amount = 0m; //decimal surplus = 0m; // 已发 decimal paid = 0m; // 奖罚,获取交易记录中奖励和处罚之和 decimal rewardAndAmercement = transactionDetailsBll.GetRewardAndAmercementAmount(employeeID); decimal others = transactionDetailsBll.GetOtherAmount(employeeID); if (empAcct != null) { amount = empAcct.AMOUNT ?? 0m; //surplus = empAcct.SURPLUSAMOUNT ?? 0m; // 已发,取员工账户表中已发的值 paid = empAcct.PAIDAMOUNT ?? 0m; //rewardAndAmercement = empAcct.REWARDANDAMERCEMENTAMOUNT ?? 0m; // 其他 //others = empAcct.OTHERSAMOUNT ?? 0m; } StringBuilder sbEmpAcct = new StringBuilder(); sbEmpAcct.Append("["); sbEmpAcct.Append("{\"value\":" + amount + ",\"name\":\"剩余\"},"); sbEmpAcct.Append("{\"value\":" + paid + ",\"name\":\"已发\"},"); sbEmpAcct.Append("{\"value\":" + Math.Abs(rewardAndAmercement) + ",\"name\":\"奖罚\"},"); sbEmpAcct.Append("{\"value\":" + Math.Abs(others) + ",\"name\":\"其他\"}"); sbEmpAcct.Append("]"); sbJsonResult.Append(sbEmpAcct); return(sbJsonResult.ToString()); }
public bool Insert_TransactionDetails(TransactionDetailsBLL t) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstrng); try { String sql = "INSERT INTO tbl_transaction_details(product_id,rate,qty,total,delr_cust_id,added_date,added_by) VALUES (@product_id,@rate,@qty,@total,@delr_cust_id,@added_date,@added_by)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@product_id", t.product_id); cmd.Parameters.AddWithValue("@rate", t.rate); cmd.Parameters.AddWithValue("@qty", t.qty); cmd.Parameters.AddWithValue("@total", t.total); cmd.Parameters.AddWithValue("@delr_cust_id", t.delr_cust_id); cmd.Parameters.AddWithValue("@added_date", t.added_date); cmd.Parameters.AddWithValue("@added_by", t.added_by); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
private void btnSaveAll_Click(object sender, EventArgs e) { TransactionBLL transaction = new TransactionBLL(); transaction.type = lblTopPurcSale.Text; string deaCusName = txtPSDeaCusName.Text; DeaCusBLL dc = dcdal.GetDeaCusIDFromName(deaCusName); transaction.delr_cust_id = dc.id; transaction.grandTotal = Math.Round(decimal.Parse(txtPSCDGrandTotal.Text), 2); transaction.transaction_date = DateTime.Now; transaction.tax = decimal.Parse(txtPSCDVat.Text); transaction.discount = decimal.Parse(txtPSCDDiscount.Text); string loggeduser = frmLogin.loggedIn; UserBLL user = udal.GetIdFromUsername(loggeduser); transaction.added_by = user.id; transaction.transactionDetails = transactionDT; bool Success = false; using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; bool X = tdal.Insert_Transaction(transaction, out transactionID); for (int i = 0; i < transactionDT.Rows.Count; i++) { TransactionDetailsBLL td = new TransactionDetailsBLL(); String ProductName = transactionDT.Rows[i][0].ToString(); ProductsBLL p = pdal.GetProductIDFromName(ProductName); td.product_id = p.id; td.rate = decimal.Parse(transactionDT.Rows[i][1].ToString()); td.qty = decimal.Parse(transactionDT.Rows[i][2].ToString()); td.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2); td.delr_cust_id = dc.id; td.added_date = DateTime.Now; td.added_by = user.id; string transactionType = lblTopPurcSale.Text; bool Y = false; if (transactionType == "PURCHASE") { Y = pdal.IncreaseProduct(td.product_id, td.qty); } else if (transactionType == "SALES") { Y = pdal.DecreaseProduct(td.product_id, td.qty); } bool Z = tdDal.Insert_TransactionDetails(td); Success = X && Y && Z; } if (Success == true) { scope.Complete(); // CODE TO PRINT BILL DGVPrinter printer = new DGVPrinter(); printer.Title = "\r\n\r\nEVERYTHING PVT. LTD.\r\n"; printer.SubTitle = "\r\n MAIN ROAD NEAR RAILWAY STATION ,P.O:GHATSILA,\r\nDIST:EAST SINGHBHUM ,JHARKHAND\r\n Mob: 9583340426 \r\n\r\n "; printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip; printer.PageNumbers = true; printer.PageNumberInHeader = false; printer.PorportionalColumns = true; printer.HeaderCellAlignment = StringAlignment.Near; printer.Footer = "Discount:" + txtPSCDDiscount.Text + "%\r\n" + "TAX:" + txtPSCDVat.Text + "%\r\n" + "Grand-Total:RS" + txtPSCDGrandTotal.Text + "\r\n\r\n" + "THANK YOU FOR BUSINESS WITH US"; printer.FooterSpacing = 15; printer.PrintDataGridView(dgvPSAddedProduct); //---------------------------------------------------------------------------------------------------------------------------- MessageBox.Show("Transaction Successfully Done."); dgvPSAddedProduct.DataSource = null; dgvPSAddedProduct.Rows.Clear(); txtPSDeaCusSearch.Text = ""; txtPSDeaCusName.Text = ""; txtPSDeaCusEmail.Text = ""; txtPSDeaCusContact.Text = ""; txtPSDeaCusAddress.Text = ""; txtPSPDSearch.Text = ""; txtPSPDName.Text = ""; txtPSPDInventory.Text = "0"; txtPSPDRate.Text = "0"; txtPSPDQty.Text = ""; txtPSCDSubtotal.Text = "0"; txtPSCDDiscount.Text = "0"; txtPSCDVat.Text = "0"; txtPSCDGrandTotal.Text = "0"; txtPSCDpaidamount.Text = "0"; txtPSCDRetAmut.Text = "0"; } else { MessageBox.Show("Failed Transaction,Retry"); } } }