private void CampaignFullyQtyAndSaleForm_Load(object sender, EventArgs e) { dateTimePickerStart.MinDate = DateTime.Now; SingletonProduct.Instance(); SingletonPriority1.Instance(); using (SSLsEntities db = new SSLsEntities()) { int currentYear = DateTime.Now.Year; int currentMonth = DateTime.Now.Month; var pro = db.PriceSchedule.Where(w => w.CreateDate.Year == currentYear && w.CreateDate.Month == currentMonth).Count() + 1; string proCodeGen = SingletonThisBudgetYear.Instance().ThisYear.CodeYear + DateTime.Now.ToString("MM") + Library.GenerateCodeFormCount(pro, 3); textBoxProCode.Text = proCodeGen; } }
/// <summary> /// ตกลง ต่อเวลา /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { using (SSLsEntities db = new SSLsEntities()) { priceSchedule = db.PriceSchedule.SingleOrDefault(w => w.Id == priceSchedule.Id); priceSchedule.StartDate = dateTimePickerStart.Value; priceSchedule.EndDate = dateTimePickerEnd.Value; priceSchedule.UpdateDate = DateTime.Now; priceSchedule.UpdateBy = Singleton.SingletonAuthen.Instance().Id; db.Entry(priceSchedule).State = EntityState.Modified; db.SaveChanges(); this.searchEditPromotionForm.Reload(); this.Dispose(); } }
private void ResetForm() { string code = ""; using (SSLsEntities db = new SSLsEntities()) { int currentYear = DateTime.Now.Year; int currentMonth = DateTime.Now.Month; var iss = db.ISS2Front.Where(w => w.CreateDate.Year == currentYear && w.CreateDate.Month == currentMonth).Count() + 1; BudgetYear budget = Singleton.SingletonThisBudgetYear.Instance().ThisYear; //Branch branch = Singleton.SingletonP code = MyConstant.PrefixForGenerateCode.StoreFrontAdd + "" + budget.CodeYear + DateTime.Now.ToString("MM") + Library.GenerateCodeFormCount(iss, 4); textBoxCode.Text = code; } }
public void setProductGroup(ComboBox cb) { using (SSLsEntities db = new SSLsEntities()) { var pgp = db.ProductGroups.Where(w => w.Enable == true).ToList(); var locationtype = pgp.Select(w => new { w.Id, w.Name }).ToList(); DataTable dt_summary = new DataTable(); dt_summary = Library.ConvertToDataTable(locationtype); dt_summary.Rows.Add(0, "ทั้งหมด"); cb.DataSource = dt_summary; cb.DisplayMember = "Name"; cb.ValueMember = "Id"; cb.SelectedIndex = dt_summary.Rows.Count - 1; } }
private void Recount() { using (SSLsEntities db = new SSLsEntities()) { string barcodescan = textBoxScanner.Text.Trim(); var getProductDetails = Singleton.SingletonProduct.Instance().ProductDetails.FirstOrDefault(w => w.Enable == true && w.Code == barcodescan); var checkFKPro = db.CheckStockDetails.FirstOrDefault(w => w.Enable == true && w.FKProductDetails == getProductDetails.Id); checkFKPro.Enable = false; checkFKPro.UpdateDate = DateTime.Now; checkFKPro.UpdateBy = _UserId; db.Entry(checkFKPro).State = EntityState.Modified; db.SaveChanges(); } ResetNew(); }
private void RefreshGrid() { using (SSLsEntities db = new SSLsEntities()) { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); DateTime dateS = dateTimePickerStart.Value; DateTime dateE = dateTimePickerEnd.Value; List <CheckStockDetails> list = new List <CheckStockDetails>(); if (_UserId == null) { list = db.CheckStockDetails.Where(w => w.Enable == true && DbFunctions.TruncateTime(w.CreateDate) >= DbFunctions.TruncateTime(dateS) && DbFunctions.TruncateTime(w.CreateDate) <= DbFunctions.TruncateTime(dateE)).OrderBy(w => w.CreateDate).ToList(); } else { list = db.CheckStockDetails.Where(w => w.Enable == true && w.CreateBy == _UserId && DbFunctions.TruncateTime(w.CreateDate) >= DbFunctions.TruncateTime(dateS) && DbFunctions.TruncateTime(w.CreateDate) <= DbFunctions.TruncateTime(dateE)).OrderBy(w => w.CreateDate).ToList(); } foreach (var item in list) { string stat = "ตรวจนับ"; if (item.ConfirmDate != null) { stat = "ยืนยัน"; } decimal total = (item.QtyUnitCheck - item.QtyUnitOnHand) * item.ProductDetails.CostAndVat; dataGridView1.Rows.Add ( item.Id, Library.ConvertDateToThaiDate(item.CreateDate), Library.GetFullNameUserById(item.CreateBy), item.ProductDetails.Code, item.ProductDetails.Products.ThaiName, item.ProductDetails.ProductUnit.Name, Library.ConvertDecimalToStringForm(item.QtyUnitOnHand), Library.ConvertDecimalToStringForm(item.QtyUnitCheck), Library.ConvertDecimalToStringForm(item.QtyUnitCheck - item.QtyUnitOnHand), Library.ConvertDecimalToStringForm(item.ProductDetails.CostAndVat), Library.ConvertDecimalToStringForm(total), stat ); } } }
/// <summary> /// ยืนยันบันทึก disable ชุดเดิมทิ้งทั้งหมด /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { List <int> ids = new List <int>(); for (int i = 0; i < dataGridView2.Rows.Count; i++) { //Console.WriteLine(); int id = int.Parse(dataGridView2.Rows[i].Cells[0].Value.ToString()); ids.Add(id); } DialogResult dr = MessageBox.Show("คุณต้องการบันทึกข้อมูล ใช่หรือไม่ ?", "คำเตือนจากระบบ", MessageBoxButtons.YesNo); switch (dr) { case DialogResult.Yes: using (SSLsEntities db = new SSLsEntities()) { var menuAc = db.MenuAccess.Where(w => w.Enable == true && w.FKRole == _idRole); foreach (var item in menuAc) { item.Enable = false; item.UpdateDate = DateTime.Now; item.UpdateBy = Singleton.SingletonAuthen.Instance().Id; db.Entry(item).State = EntityState.Modified; } // add new ids foreach (var item in ids) { MenuAccess ac = new MenuAccess(); ac.CreateBy = Singleton.SingletonAuthen.Instance().Id; ac.CreateDate = DateTime.Now; ac.FKRole = _idRole; ac.FKMenu = item; ac.UpdateDate = DateTime.Now; ac.UpdateBy = Singleton.SingletonAuthen.Instance().Id; ac.Enable = true; db.MenuAccess.Add(ac); } db.SaveChanges(); ReloaGrid1(); } break; case DialogResult.No: break; } }
public void ReloadGrid() { using (SSLsEntities db = new SSLsEntities()) { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); DateTime dateS = dateTimePickerStart.Value; DateTime dateE = dateTimePickerEnd.Value; List <StoreFrontTransferOut> list = new List <StoreFrontTransferOut>(); list = db.StoreFrontTransferOut.Where(w => DbFunctions.TruncateTime(w.CreateDate) >= DbFunctions.TruncateTime(dateS) && DbFunctions.TruncateTime(w.CreateDate) <= DbFunctions.TruncateTime(dateE)).OrderBy(w => w.CreateDate).ToList(); decimal total = 0; foreach (var item in list) { string status = ""; if (item.Enable == false) { status = "ยกเลิกใบโอน"; } else if (item.ConfirmDate != null) { status = "ยืนยันใบโอน"; } else { status = "สร้างใบโอน"; } dataGridView1.Rows.Add( false, Library.ConvertDateToThaiDate(item.CreateDate), Library.GetFullNameUserById(item.CreateBy), item.Code, item.StoreFrontTransferOutDtl.Where(w => w.Enable == true).ToList().Count(), Library.ConvertDecimalToStringForm(item.TotalQtyUnit), Library.ConvertDecimalToStringForm(item.TotalBalance), status, item.Branch.Name + " " + item.Branch.BranchNo, item.Remark ); total += item.TotalBalance; } textBoxQtyList.Text = list.Count() + ""; textBoxTotalBalance.Text = Library.ConvertDecimalToStringForm(total); } }
private void SaveCommit() { using (SSLsEntities db = new SSLsEntities()) { string username = Singleton.SingletonAuthen.Instance().Id; var data = db.Users.SingleOrDefault(w => w.Id == username); data.UpdateBy = Singleton.SingletonAuthen.Instance().Id; data.UpdateDate = DateTime.Now; data.Name = textBoxFullName.Text; data.Description = textBoxDesc.Text; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); this.Dispose(); } }
private void PopupProductBaseForm_Load(object sender, EventArgs e) { using (SSLsEntities db = new SSLsEntities()) { var prod = db.ProductDetails.SingleOrDefault(w => w.Id == idProDtl); var prodDtlList = db.ProductDetails.Where(w => w.FKProduct == prod.FKProduct && w.Enable == true); foreach (var item in prodDtlList) { dataGridView1.Rows.Add(item.Id, item.Code, item.PackSize, item.ProductUnit.Name, Library.ConvertDecimalToStringForm(item.CostOnly)); } } }
private void WmsTransferBranchForm_Load(object sender, EventArgs e) { string code = ""; using (SSLsEntities db = new SSLsEntities()) { int currentYear = DateTime.Now.Year; int currentMonth = DateTime.Now.Month; var wto = db.WmsTransferOut.Where(w => w.CreateDate.Year == currentYear && w.CreateDate.Month == currentMonth).Count() + 1; BudgetYear budget = Singleton.SingletonThisBudgetYear.Instance().ThisYear; //Branch branch = Singleton.SingletonP code = MyConstant.PrefixForGenerateCode.WmsTransferOut + "" + budget.CodeYear + DateTime.Now.ToString("MM") + Library.GenerateCodeFormCount(wto, 4); textBoxCode.Text = code; textBoxTODate.Text = Library.ConvertDateToThaiDate(DateTime.Now); } }
private void WastManageDetailForm_Load(object sender, EventArgs e) { using (SSLsEntities db = new SSLsEntities()) { var data = db.StoreFrontTransferWasteDtl.Where(w => w.Enable == true && w.FKStoreFrontTransferWaste == code).ToList(); foreach (var item in data) { dataGridView1.Rows.Add(item.Id, item.ProductDetails.Code, item.ProductDetails.Products.ThaiName, item.ProductDetails.PackSize, item.Qty, Library.ConvertDecimalToStringForm(item.CostPerUnit), item.Description); } textBox1.Text = code; textBox2.Text = Library.ConvertDateToThaiDate(data.FirstOrDefault().CreateDate); } }
private void SendAutoMapper(POHeader item) { using (SSLsEntities db = new SSLsEntities()) { POHeader po = new POHeader(); po.ApproveBy = null; po.ApproveDate = null; po.UnApproveDate = null; po.UpApproveBy = null; po.UpApproveRemark = null; po.Enable = true; db.POHeader.Add(po); db.SaveChanges(); } }
private void GoodsAutoReturnWmsForm_Load(object sender, EventArgs e) { textBoxDate.Text = Library.ConvertDateToThaiDate(DateTime.Now); string code = ""; using (SSLsEntities db = new SSLsEntities()) { int currentYear = DateTime.Now.Year; int currentMonth = DateTime.Now.Month; var cnw = db.CNWarehouse.Where(w => w.CreateDate.Year == currentYear && w.CreateDate.Month == currentMonth).Count() + 1; BudgetYear budget = Singleton.SingletonThisBudgetYear.Instance().ThisYear; //Branch branch = Singleton.SingletonP code = MyConstant.PrefixForGenerateCode.GoodsReturnCN + "" + budget.CodeYear + DateTime.Now.ToString("MM") + Library.GenerateCodeFormCount(cnw, 4); textBoxCode.Text = code; } }
/// <summary> /// ปริ้นออเดอร์ /// </summary> /// <param name="codeSelected"></param> private void PrintOrderOrder(IEnumerable<string> codeSelected) { using (SSLsEntities db = new SSLsEntities()) { List<string> invs = new List<string>(); foreach (var item in codeSelected) { var data = db.SaleOrderWarehouse.FirstOrDefault(w => w.Enable == true && w.Code == item); invs.Add(data.InvoiceNo); } _Inv = invs; } Thread print = new Thread(ThreadPrint); print.Start(); }
private void CancelOrder(IEnumerable<string> stackDocNo) { using (SSLsEntities db = new SSLsEntities()) { foreach (var item in stackDocNo) { var order = db.SaleOrderWarehouse.SingleOrDefault(w => w.Code == item); order.UpdateDate = DateTime.Now; order.UpdateBy = Singleton.SingletonAuthen.Instance().Id; order.Enable = false; order.FKSaleOrderWarehouseStatus = MyConstant.SaleOrderWarehouseStatus.CancelOrder; db.Entry(order).State = EntityState.Modified; } db.SaveChanges(); LoadGrid(); } }
void AddStockHD(int id) { using (SSLsEntities db = new SSLsEntities()) { StoreFrontStock hd = new StoreFrontStock(); hd.Description = "-"; hd.CreateDate = DateTime.Now; hd.CreateBy = Singleton.SingletonAuthen.Instance().Id; hd.UpdateDate = DateTime.Now; hd.UpdateBy = Singleton.SingletonAuthen.Instance().Id; hd.Enable = true; hd.CurrentQty = 0; hd.FKProduct = id; db.StoreFrontStock.Add(hd); db.SaveChanges(); } }
/// <summary> /// product id dtl /// </summary> /// <param name="id"></param> public void BinddingProductDtChoose(int id) { using (SSLsEntities db = new SSLsEntities()) { var getNewProduct = db.ProductDetails.SingleOrDefault(w => w.Id == id); int row = dataGridView1.CurrentRow.Index; //int idpo = int.Parse(dataGridView1.Rows[row].Cells[colIdPo].Value.ToString()); //int idProd = int.Parse(dataGridView1.Rows[row].Cells[colIdProd].Value.ToString()); dataGridView1.Rows[row].Cells[colIdProd].Value = id; //int number = int.Parse(dataGridView1.Rows[row].Cells[colNumber].Value.ToString()); //string code = dataGridView1.Rows[row].Cells[colCode].Value.ToString(); dataGridView1.Rows[row].Cells[colCode].Value = getNewProduct.Code; decimal pz = decimal.Parse(dataGridView1.Rows[row].Cells[colPz].Value.ToString()); decimal rcvComplete = decimal.Parse(dataGridView1.Rows[row].Cells[colRcvComplete].Value.ToString()); decimal pieceRcvComplete = rcvComplete * pz; dataGridView1.Rows[row].Cells[colRcvComplete].Value = Library.ConvertDecimalToStringForm(pieceRcvComplete / getNewProduct.PackSize); decimal qty = decimal.Parse(dataGridView1.Rows[row].Cells[colQty].Value.ToString()); decimal piece = qty * pz; dataGridView1.Rows[row].Cells[colPz].Value = getNewProduct.PackSize; //string unit = dataGridView1.Rows[row].Cells[colUnit].Value.ToString(); dataGridView1.Rows[row].Cells[colUnit].Value = getNewProduct.ProductUnit.Name; dataGridView1.Rows[row].Cells[colQty].Value = Library.ConvertDecimalToStringForm(piece / getNewProduct.PackSize); decimal gift = decimal.Parse(dataGridView1.Rows[row].Cells[colGift].Value.ToString()); dataGridView1.Rows[row].Cells[colGift].Value = Library.ConvertDecimalToStringForm((gift * pz) / getNewProduct.PackSize); decimal rcvQty = decimal.Parse(dataGridView1.Rows[row].Cells[colRcvQty].Value.ToString()); dataGridView1.Rows[row].Cells[colRcvQty].Value = Library.ConvertDecimalToStringForm(0); decimal rcvGift = decimal.Parse(dataGridView1.Rows[row].Cells[colRcvGift].Value.ToString()); dataGridView1.Rows[row].Cells[colRcvGift].Value = Library.ConvertDecimalToStringForm(0); //decimal price = decimal.Parse(dataGridView1.Rows[row].Cells[colPrice].Value.ToString()); dataGridView1.Rows[row].Cells[colPrice].Value = Library.ConvertDecimalToStringForm(0); //decimal total = decimal.Parse(dataGridView1.Rows[row].Cells[colTotal].Value.ToString()); qty = decimal.Parse(dataGridView1.Rows[row].Cells[colQty].Value.ToString()); dataGridView1.Rows[row].Cells[colTotal].Value = Library.ConvertDecimalToStringForm(0); int poDtlId = int.Parse(dataGridView1.Rows[row].Cells[colPODtlId].Value.ToString()); } }
/// <summary> /// ปุ่มค้นหา /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { using (SSLsEntities db = new SSLsEntities()) { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); DateTime dateS = dateTimePickerStart.Value; DateTime dateE = dateTimePickerEnd.Value; bool checkNotRcv = checkBoxNotRcv.Checked; bool checkRcv = checkBoxRcv.Checked; //var data = _poList.Where(w => //DbFunctions.TruncateTime(w.CreateDate) >= DbFunctions.TruncateTime(dateS) && //DbFunctions.TruncateTime(w.CreateDate) <= DbFunctions.TruncateTime(dateE) //).ToList(); var data = _poList.Where(w => int.Parse(w.CreateDate.ToString("yyyyMMdd")) >= int.Parse(dateS.ToString("yyyyMMdd")) && int.Parse(w.CreateDate.ToString("yyyyMMdd")) <= int.Parse(dateE.ToString("yyyyMMdd")) ).ToList(); if (checkNotRcv == true && checkRcv == true) { } else if (checkNotRcv == true && checkRcv == false) // เอาเฉพาะ ไม่เคยรับเข้า { data = data.Where(w => w.FKPOStatus == MyConstant.POStatus.NotRCV).ToList(); } else if (checkNotRcv == false && checkRcv == true) // เอาเฉพาะ เคยรับเข้าแล้ว { data = data.Where(w => w.FKPOStatus == MyConstant.POStatus.RCVNotEnd).ToList(); } else { //data = data.Where(w => w.FKPOStatus == MyConstant.POStatus.RCVNotEnd).ToList(); MessageBox.Show("เงื่อนไขค้นหาไม่ถูกต้อง"); return; } foreach (var item in data) { // จำนวนหน่วยทั้งหมดของ PO ไม่นับของแถม decimal getQtyInPO = item.PODetail.Where(w => w.Enable == true).ToList().Sum(w => (w.Qty + w.GiftQty)); decimal getRcvQtyInPO = item.PODetail.Where(w => w.Enable == true).ToList().Sum(w => (w.RcvQty + w.RcvGiftQty)); decimal percent = Library.GetPercentFromValue(getRcvQtyInPO, getQtyInPO); dataGridView1.Rows.Add(item.Id, Library.ConvertDateToThaiDate(item.CreateDate), item.PONo, Library.ConvertDateToThaiDate(item.POExpire), item.POStatus.Name, item.Vendor.Name, Library.ConvertDecimalToStringForm(percent) + " %"); } } }
public static List <string> GetAllDocId(string Code_S, string Code_E) { using (SSLsEntities db = new SSLsEntities()) { List <string> fkProHd = new List <string>(); try { var allDoc = db.StoreFrontValueDoc.Where(w => w.Enable == true).OrderBy(w => w.DocNo); if (Code_S == "") { fkProHd.AddRange(allDoc.Select(w => w.DocNo).Distinct().ToList <string>()); return(fkProHd); } else if (Code_S == Code_E) { fkProHd.Add(Code_S); return(fkProHd); } bool found = false; foreach (var item in allDoc) { if (found == true && item.DocNo != Code_E) { fkProHd.Add(item.DocNo); } else if (item.DocNo == Code_S) { found = true; fkProHd.Add(item.DocNo); } else if (item.DocNo == Code_E) { fkProHd.Add(item.DocNo); break; } } return(fkProHd.Distinct().ToList <string>());; } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(fkProHd); } } }
private void Reload() { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); dataGridView2.Rows.Clear(); dataGridView2.Refresh(); using (SSLsEntities db = new SSLsEntities()) { var data = db.PriceSchedule.SingleOrDefault(w => w.Id == id); var selling = data.SellingPrice.Where(w => w.Enable == true).ToList(); foreach (var item in selling) { dataGridView1.Rows.Add(item.Id, item.ProductDetails.Code, item.ProductDetails.Products.ThaiName, item.ProductDetails.ProductUnit.Name, Library.ConvertDecimalToStringForm(item.ProductDetails.SellPrice), item.Description); } textBoxProAmount.Text = Library.ConvertDecimalToStringForm(data.FullQty); foreach (SellingPriceDetails item in data.SellingPrice.FirstOrDefault().SellingPriceDetails.Where(w => w.Enable == true).ToList()) { dataGridView2.Rows.Add(item.Id, item.ProductDetails.Code, item.ProductDetails.Products.ThaiName, item.ProductDetails.ProductUnit.Name, Library.ConvertDecimalToStringForm(item.ProductDetails.SellPrice), Library.ConvertDecimalToStringForm(item.SpecialPrice), item.Description, item.FKProduct); } /// check หมดเขต หรือ disable if (data.Enable == false) { // ยกเลิกแล้ว button3.Enabled = false; label1.Text = "* ยกเลิกแล้ว"; label1.Visible = true; button2.Enabled = false; label2.Text = "* ยกเลิกแล้ว"; label2.Visible = true; } else if (data.IsStop == true) { // หมดเขตแล้ว button3.Enabled = false; label1.Text = "* หมดเขตแล้ว"; label1.Visible = true; button2.Enabled = false; label2.Text = "* หมดเขตแล้ว"; label2.Visible = true; } } RowColor(); RowColor(2); }
/// <summary> /// ยอดยกไป /// </summary> /// <param name="fkProHD"></param> /// <param name="startdDate"></param> /// <param name="endDate"></param> /// <returns></returns> public decimal GetBalance(int fkProHD, DateTime startdDate, DateTime endDate) { decimal resultForProDtl = GetResult(fkProHD, startdDate); try { using (SSLsEntities db = new SSLsEntities()) { List <StoreFrontStockDetails> details = db.StoreFrontStock.FirstOrDefault(w => w.FKProduct == fkProHD && w.Enable == true) .StoreFrontStockDetails.Where(w => w.Enable == true && int.Parse(w.CreateDate.ToString("yyyyMMdd")) >= int.Parse(startdDate.ToString("yyyyMMdd")) && int.Parse(w.CreateDate.ToString("yyyyMMdd")) <= int.Parse(endDate.ToString("yyyyMMdd")) ).OrderBy(w => w.CreateDate).ToList(); if (details.Count() == 0) { return(0); } else { foreach (var trans in details) { decimal plus = 0; decimal minus = 0; if (trans.TransactionType.IsPlus == true) { plus = trans.ActionQty; resultForProDtl = resultForProDtl + plus; } else { minus = trans.ActionQty; resultForProDtl = resultForProDtl - minus; } } } return(resultForProDtl); } } catch (Exception ex) { MessageBox.Show(ex.Message, "แจ้งเตือนจากระบบ!!", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void button2_Click(object sender, EventArgs e) { using (SSLsEntities db = new SSLsEntities()) { if (_Id == 0) { // add new ProductGroups obj = new ProductGroups(); obj.Code = textBoxCode.Text; obj.Name = textBoxName.Text; obj.Description = textBoxDesc.Text; obj.CreateDate = DateTime.Now; obj.CreateBy = Singleton.SingletonAuthen.Instance().Id; obj.Enable = true; obj.UpdateBy = Singleton.SingletonAuthen.Instance().Id; obj.UpdateDate = DateTime.Now; db.ProductGroups.Add(obj); } else { // edit var obj = db.ProductGroups.SingleOrDefault(w => w.Id == _Id); obj.UpdateDate = DateTime.Now; obj.UpdateBy = Singleton.SingletonAuthen.Instance().Id; obj.Code = textBoxCode.Text; obj.Name = textBoxName.Text; obj.Description = textBoxDesc.Text; if (radioButton1.Checked) { obj.Enable = true; } else { obj.Enable = false; } db.Entry(obj).State = EntityState.Modified; } db.SaveChanges(); Singleton.SingletonPriority1.SetInstance(); //Singleton.SingletonPriority1.Instance(); dataGrid(); //this.Dispose(); //_Id = 0; } }
/// <summary> /// ค้นหาทั้งหมด /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button4_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); /// Get สินค้าห้องของเสีย IEnumerable <int> allProductInVendor = Singleton.SingletonProduct.Instance().Products.Where(w => w.Enable == true).Select(w => w.Id).Distinct().ToList <int>(); using (SSLsEntities db = new SSLsEntities()) { var waste = db.WasteWarehouse.Where(w => w.Enable == true && allProductInVendor.Contains(w.FKProduct) && w.QtyUnit > 0).ToList(); /// ตรวจพบสินค้า vendor ในห้องของเสีย foreach (var item in waste) { IEnumerable <int> fkProductDtls = item.WasteWarehouseDetails.Where(w => w.Enable == true && w.LastResultUnit > 0).Select(w => w.FKProductDetails).Distinct().ToList <int>(); /// Bindding Data Grid foreach (var last in fkProductDtls) { var getLast = item.WasteWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == last).OrderByDescending(w => w.CreateDate).FirstOrDefault(); // get ค่าจากใบทำคืนที่ ยังไม่คอนเฟิม decimal qtyCNNotComplete = 0; var cnData = db.CNWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == getLast.FKProductDetails && w.CNWarehouse.ConfirmCNDate == null && w.CNWarehouse.Enable == true).ToList(); if (cnData != null) { qtyCNNotComplete = cnData.Sum(w => w.Qty); } /// from ห้องของเสีย dataGridView1.Rows.Add ( getLast.FKProductDetails, getLast.ProductDetails.Code, getLast.ProductDetails.Products.ThaiName, getLast.ProductDetails.ProductUnit.Name, Library.ConvertDecimalToStringForm(getLast.LastResultUnit), Library.ConvertDecimalToStringForm(qtyCNNotComplete),// ยอดที่รอการคอนเฟิม หลังจากส่งคืน getLast.Packsize, Library.ConvertDecimalToStringForm(getLast.ProductDetails.CostOnly), Library.ConvertDecimalToStringForm(getLast.ProductDetails.CostOnly * getLast.QtyUnit), "-" ); } } TotalSummary(); } }
/// <summary> /// คำนวน Order ใหม่ /// </summary> /// <param name="code"></param> private void Recal(string code) { using (SSLsEntities db = new SSLsEntities()) { var data = db.SaleOrderWarehouse.SingleOrDefault(w => w.Code == code); decimal totalHasVat = 0; // ยอดสินค้ามีภาษี decimal totalUnVat = 0; // ยอดสินค้ายกเว้นภาษี decimal totalDisInList = 0; foreach (var item in data.SaleOrderWarehouseDtl.Where(w => w.Enable == true).ToList()) { if (item.QtyAllow < item.Qty) { // ได้ยอดไม่ตามเป้า item.QtyOriginal = item.Qty; item.Qty = item.QtyAllow; // clear ส่วนลด item.PercentDiscount = 0; item.BathDiscount = 0; item.TotalPrice = item.QtyAllow * item.PricePerUnit; db.Entry(item).State = EntityState.Modified; } if (item.ProductDetails.Products.ProductVatType.Id == MyConstant.ProductVatType.HasVat) { totalHasVat += item.TotalPrice; } else { totalUnVat += item.TotalPrice; } totalDisInList += item.BathDiscount; } decimal total = totalHasVat + totalUnVat; // ยอดรวมก่อนหักลด decimal totalBalance = total - data.TotalDiscount; data.TotalVat = totalHasVat * MyConstant.MyVat.Vat / MyConstant.MyVat.VatRemove; data.TotaNoVat = totalUnVat; data.TotalBeforeVat = totalHasVat - data.TotalVat; data.Total = total; data.TotalDiscountInList = totalDisInList; data.TotalBalance = totalBalance; db.SaveChanges(); } }
private void ReportStockCard_Load(object sender, EventArgs e) { button3.Enabled = false; button4.Enabled = false; checkBoxProduct.Checked = true; lb_msg.Visible = false; var getPdtl = Singleton.SingletonProduct.Instance().ProductDetails.Where(w => w.Enable == true).ToList(); AutoCompleteStringCollection colPdtl = new AutoCompleteStringCollection(); foreach (var item in getPdtl) { colPdtl.Add(item.Code); } textBox1.AutoCompleteCustomSource = colPdtl; var getPdg = Singleton.SingletonProduct.Instance().ProductDetails.Where(w => w.Enable == true).ToList(); AutoCompleteStringCollection colPdg = new AutoCompleteStringCollection(); foreach (var item in getPdg) { colPdg.Add(item.Code); } textBox2.AutoCompleteCustomSource = colPdg; SSLsEntities db = new SSLsEntities(); var combo = db.ProductGroups.Where(w => w.Enable == true).Select(s => new { s.Id, s.Name }).OrderBy(o => o.Id).ToList(); DataTable dt_summary = new DataTable(); DataTable dt_summary2 = new DataTable(); dt_summary = CodeFileDLL.ConvertToDataTable(combo); dt_summary2 = CodeFileDLL.ConvertToDataTable(combo); dt_summary.Rows.Add(0, "ทั้งหมด"); comboBox1.DataSource = dt_summary; comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Id"; comboBox1.SelectedIndex = dt_summary.Rows.Count - 1; dt_summary2.Rows.Add(0, "ทั้งหมด"); comboBox2.DataSource = dt_summary2; comboBox2.DisplayMember = "Name"; comboBox2.ValueMember = "Id"; comboBox2.SelectedIndex = dt_summary2.Rows.Count - 1; }
/// <summary> /// ตรวจสอบ Promotion หยุดทำงาน /// </summary> private void CheckPromorionstop() { using (SSLsEntities db = new SSLsEntities()) { var dateQuery = db.Database.SqlQuery <DateTime>("SELECT getdate()"); DateTime serverDate = dateQuery.AsEnumerable().First(); var dateCheck = db.PriceScheduleCheck.FirstOrDefault(w => DbFunctions.TruncateTime(w.DateCheck) == DbFunctions.TruncateTime(serverDate)); if (dateCheck.IsCheck == false) { // ถ้าวันนี้ ยังไม่เชค ก็เชค dateCheck.IsCheck = true; dateCheck.CheckDate = serverDate; dateCheck.CheckBy = SingletonAuthen.Instance().Id; db.Entry(dateCheck).State = EntityState.Modified; var priceSchedule = db.PriceSchedule.Where(w => w.Enable == true && w.IsStop == false); foreach (var item in priceSchedule) { if (serverDate > item.EndDate) { // ถ้าวันนี้ มากกว่า วันสิ้นสุด // โปรโมชั่น ควร Stop ลง item.IsStop = true; item.StopReason = "Stop By Code"; item.UpdateDate = DateTime.Now; item.UpdateBy = SingletonAuthen.Instance().Id; db.Entry(item).State = EntityState.Modified; } } db.SaveChanges(); } else { // ถ้าวันนี้ เชคแล้ว ปล่อยผ่าน } //int days = 1000; //for (int i = 0; i < days; i++) //{ // PriceScheduleCheck f = new PriceScheduleCheck(); // f.DateCheck = DateTime.Now.AddDays(i + 1); // f.IsCheck = false; // db.PriceScheduleCheck.Add(f); //} //db.SaveChanges(); } }
private List <ยกมาของเสย> Getยกมา() { using (SSLsEntities db = new SSLsEntities()) { string date = dateTimePickerStart.Value.ToString("yyyyMMdd"); string query = @"SELECT TOP (100) PERCENT wms.WasteWarehouseDetails.CreateDate, CONVERT(varchar, wms.WasteWarehouseDetails.CreateDate, 112) AS DateStr, wms.WasteWarehouseDetails.CreateBy, wms.ProductDetails.FKProduct, wms.WasteWarehouseDetails.FKProductDetails, wms.WasteWarehouseDetails.QtyPiece, wms.WasteWarehouseDetails.IsInOrOut, wms.Products.FKVender FROM wms.WasteWarehouseDetails INNER JOIN wms.ProductDetails ON wms.WasteWarehouseDetails.FKProductDetails = wms.ProductDetails.Id INNER JOIN wms.Products ON wms.ProductDetails.FKProduct = wms.Products.Id WHERE (wms.WasteWarehouseDetails.Enable = 1) AND (wms.ProductDetails.Enable = 1) AND (CONVERT(varchar, wms.WasteWarehouseDetails.CreateDate, 112) < '{0}') AND (wms.Products.Enable = 1) AND (wms.Products.FKVender = {1}) ORDER BY wms.WasteWarehouseDetails.CreateDate DESC"; String s = String.Format(query, date, _VId); var data = db.Database.ExecuteEntities <ยกมาของเสย>(s).ToList(); return(data); } }
private void POListNotCompleteForm_Load(object sender, EventArgs e) { _poList = new List <POHeader>(); using (SSLsEntities db = new SSLsEntities()) { _poList = db.POHeader.Include("PaymentType").Include("POStatus").Include("PODetail.ProductDetails.Products").Include("PODetail.ProductDetails.ProductUnit").Include("Vendor.POCostType").Include("PORcv.PORcvDetails").Include("PORcv.PORcvDetails") .Where(w => w.Enable == true && w.ApproveDate != null && (w.FKPOStatus == MyConstant.POStatus.NotRCV || w.FKPOStatus == MyConstant.POStatus.RCVNotEnd)).ToList(); } foreach (var item in _poList) { // จำนวนหน่วยทั้งหมดของ PO ไม่นับของแถม decimal getQtyInPO = item.PODetail.Where(w => w.Enable == true).ToList().Sum(w => (w.Qty + w.GiftQty)); decimal getRcvQtyInPO = item.PODetail.Where(w => w.Enable == true).ToList().Sum(w => (w.RcvQty + w.RcvGiftQty)); decimal percent = Library.GetPercentFromValue(getRcvQtyInPO, getQtyInPO); dataGridView1.Rows.Add(item.Id, Library.ConvertDateToThaiDate(item.CreateDate), item.PONo, Library.ConvertDateToThaiDate(item.POExpire), item.POStatus.Name, item.Vendor.Name, Library.ConvertDecimalToStringForm(percent) + " %"); } }
private void PrintConfirm() { int seq = int.Parse(textBoxKeyValue.Text.Trim()); if (seq > v) { MessageBox.Show("ไม่ถูกต้อง"); } else { using (SSLsEntities db = new SSLsEntities()) { var data = db.POHeader.SingleOrDefault(w => w.SequenceEdit == seq && w.PONo == _code); MainReportViewer mr = new MainReportViewer(data.Id); mr.ShowDialog(); } } }