コード例 #1
0
 private string GetStatusPO(POHeader item)
 {
     if (item.ApproveDate == null && item.NotApproveDate == null)
     {
         return("รออนุมัติ");
     }
     else if (item.ApproveDate != null)
     {
         return("อนุมัติแล้ว");
     }
     else if (item.ApproveDate == null && item.NotApproveDate != null)
     {
         return("ไม่อนุมัติ");
     }
     else
     {
         return("");
     }
 }
コード例 #2
0
        /// <summary>
        /// หลัง save เสร็จ reset ใหม่
        /// </summary>
        private void ResetRcv()
        {
            textBoxPONo.Text       = "";
            textBoxPODate.Text     = "";
            textBoxPayType.Text    = "";
            textBoxReferNo.Text    = "";
            textBoxExpireDate.Text = "";
            _po = null;
            textBoxVendorCode.Text     = "";
            textBoxVendorName.Text     = "";
            textBoxVendorCostType.Text = "";

            textBoxDiscountKey.Text  = "0.00";
            textBoxDiscountBath.Text = "0.00";
            textBoxTotalUnVat.Text   = "0.00";
            textBoxTotalHasVat.Text  = "0.00";
            textBoxTotalVat.Text     = "0.00";
            textBoxTotalBalance.Text = "0.00";
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();
        }
コード例 #3
0
        /// <summary>
        /// from search
        /// </summary>
        void BinddingDataGrid()
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();
            string keyPO = textBoxPONo.Text.Trim();

            using (SSLsEntities db = new SSLsEntities())
            {
                int i    = 1;
                var data = db.POHeader.Include("PaymentType").Include("POStatus").Include("PODetail.ProductDetails.Products").Include("PODetail.ProductDetails.ProductUnit").Include("Vendor.POCostType").Include("PORcv.PORcvDetails").Include("PORcv.PORcvDetails").FirstOrDefault(w => w.Enable == true && w.ApproveDate != null && (w.FKPOStatus == MyConstant.POStatus.NotRCV || w.FKPOStatus == MyConstant.POStatus.RCVNotEnd) && w.PONo == keyPO);
                if (data == null)
                {
                    MessageBox.Show("ไม่พบ PO นี้");
                    return;
                }
                _po = data;
                foreach (var item in data.PODetail.Where(w => w.Enable == true).ToList())
                {
                    // จำนวนรับ default is 0 ก่อน
                    decimal getcost = item.CostOnly;
                    if (data.Vendor.FKPOCostType == MyConstant.POCostType.CostAndVat)
                    {
                        getcost = item.CostAndVat;
                    }
                    // check ถ้ามีการรับเข้าแล้ว
                    decimal gift = 0;
                    if (data.FKPOStatus == MyConstant.POStatus.RCVNotEnd)
                    {
                        // แสดงว่าเคยทำงานรับเข้าแล้ว
                        gift = item.RcvGiftQty;
                    }
                    dataGridView1.Rows.Add(item.Id,
                                           0,
                                           item.ProductDetails.Code,
                                           item.ProductDetails.Products.ThaiName,
                                           item.ProductDetails.ProductUnit.Name,
                                           (item.Qty + item.GiftQty),
                                           (item.RcvGiftQty + item.RcvQty),
                                           Library.ConvertDecimalToStringForm(getcost),
                                           0,
                                           item.DiscountInput,
                                           Library.ConvertDecimalToStringForm(item.DiscountBath),
                                           0.00,
                                           0.00,
                                           item.GiftQty);
                    i++;
                }
                // Bindding Details
                textBoxPONo.Text           = data.PONo;
                textBoxPODate.Text         = Library.ConvertDateToThaiDate(data.CreateDate);
                textBoxPayType.Text        = data.PaymentType.Name;
                textBoxReferNo.Text        = data.ReferenceNo;
                textBoxExpireDate.Text     = Library.ConvertDateToThaiDate(data.POExpire);
                textBoxVendorCode.Text     = data.Vendor.Code;
                textBoxVendorName.Text     = data.Vendor.Name;
                textBoxVendorCostType.Text = data.Vendor.POCostType.Name;
                // set summary
                textBoxDiscountKey.Text  = "0.00";
                textBoxDiscountBath.Text = "0.00";
                textBoxTotalUnVat.Text   = "0.00";
                textBoxTotalHasVat.Text  = "0.00";
                textBoxTotalVat.Text     = "0.00";
                textBoxTotalBalance.Text = "0.00";
            }
        }
コード例 #4
0
 public PODetailsDialog(POHeader data)
 {
     InitializeComponent();
     this.data = data;
 }
コード例 #5
0
        private void UnApproveSave()
        {
            List <int> idsPO = new List <int>();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                var    po    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                string check = "";
                if (dataGridView1.Rows[i].Cells[9].Value == null)
                {
                    check = "FALSE";
                }
                else
                {
                    check = dataGridView1.Rows[i].Cells[9].Value.ToString();
                }

                var id = dataGridView1.Rows[i].Cells[0].Value.ToString();
                Console.WriteLine(id + " " + po + " --------- " + check);
                if (check.ToUpper() == "TRUE")
                {
                    idsPO.Add(int.Parse(id));
                }
            }
            Console.WriteLine(idsPO.Count());
            if (idsPO.Count() < 1)
            {
                MessageBox.Show("ไม่มีพบเลือกรายการ");
                return;
            }
            else if (idsPO.Count() > 0 && textBoxNotApproveRemark.Text == "")
            {
                MessageBox.Show("กรุณากรอกเหตุผล");
                return;
            }
            using (SSLsEntities db = new SSLsEntities())
            {
                var             pos      = db.POHeader.Include("PODetail").Where(w => idsPO.Contains(w.Id)).ToList();
                List <POHeader> poAddNew = new List <POHeader>();
                foreach (var item in pos)
                {
                    if (item.ApproveDate != null)
                    {
                        // add new ก่อน
                        POHeader po = new POHeader();
                        po.FKBranch           = item.FKBranch;
                        po.FKVender           = item.FKVender;
                        po.PONo               = item.PONo;
                        po.PODate             = item.PODate;
                        po.FKBudgetYear       = item.FKBudgetYear;
                        po.ReferenceNo        = item.ReferenceNo;
                        po.DueDate            = item.DueDate;
                        po.POExpire           = item.POExpire;
                        po.FKPaymentType      = item.FKPaymentType;
                        po.DiscountInput      = item.DiscountInput;
                        po.DiscountBath       = item.DiscountBath;
                        po.DiscountPercent    = item.DiscountPercent;
                        po.Description        = item.Description;
                        po.NotApproveDate     = item.NotApproveDate;
                        po.NotApproveBy       = item.NotApproveBy;
                        po.NotApproveRemark   = item.NotApproveRemark;
                        po.ApproveBy          = null;
                        po.ApproveDate        = null;
                        po.TotalPrice         = item.TotalPrice;
                        po.TotalHasVat        = item.TotalHasVat;
                        po.TotalUnVat         = item.TotalUnVat;
                        po.TotalDiscount      = item.TotalDiscount;
                        po.TotalPriceDiscount = item.TotalPriceDiscount;
                        po.TotalVat           = item.TotalVat;
                        po.TotalBalance       = item.TotalBalance;
                        po.TotalQty           = item.TotalQty;
                        po.TotalGift          = item.TotalGift;
                        po.CreateDate         = item.CreateDate;
                        po.CreateBy           = item.CreateBy;
                        po.UpdateDate         = item.UpdateDate;
                        po.UpdateBy           = item.UpdateBy;
                        po.Enable             = true;
                        po.FKPOStatus         = item.FKPOStatus;
                        po.UnApproveDate      = null;
                        po.UpApproveBy        = null;
                        po.UpApproveRemark    = null;
                        po.SequenceEdit       = item.SequenceEdit + 1;

                        List <PODetail> details = new List <PODetail>();
                        PODetail        dtl;
                        foreach (var d in item.PODetail.Where(w => w.Enable == true).ToList())
                        {
                            dtl = new PODetail();
                            dtl.FKProductDetail = d.FKProductDetail;
                            dtl.Qty             = d.Qty;
                            dtl.GiftQty         = d.GiftQty;
                            dtl.CostOnly        = d.CostOnly;
                            dtl.CostAndVat      = d.CostAndVat;
                            dtl.DiscountInput   = d.DiscountInput;
                            dtl.DiscountBath    = d.DiscountBath;
                            dtl.TotalCost       = d.TotalCost;
                            dtl.CreateDate      = d.CreateDate;
                            dtl.CreateBy        = d.CreateBy;
                            dtl.UpdateDate      = d.UpdateDate;
                            dtl.UpdateBy        = d.UpdateBy;
                            dtl.Enable          = d.Enable;
                            dtl.RcvQty          = d.RcvQty;
                            dtl.RcvGiftQty      = d.RcvGiftQty;
                            dtl.InterfaceDate   = d.InterfaceDate;
                            dtl.Sequence        = po.SequenceEdit;
                            po.PODetail.Add(dtl);
                        }
                        db.POHeader.Add(po);
                        ///////////////////////////////////// disableตัวเดิมทิ้ง
                        item.UnApproveDate   = DateTime.Now;
                        item.UpApproveBy     = Singleton.SingletonAuthen.Instance().Id;
                        item.UpApproveRemark = textBoxNotApproveRemark.Text;
                        item.Enable          = false;
                        db.Entry(item).State = EntityState.Modified;
                        foreach (var dtlForDisable in item.PODetail.Where(w => w.Enable == true).ToList())
                        {
                            // disable รายละเอียด
                            dtlForDisable.Enable          = false;
                            db.Entry(dtlForDisable).State = EntityState.Modified;
                        }
                        //SendAutoMapper(item);
                        //POHeader po = (POHeader)Mapper.Map<POHeader>(item);
                        //poAddNew.Add(po);
                        //db.POHeader.Attach(po);
                        //db.POHeader.Add(po);
                        //POHeader po = new POHeader();
                        //po = item;
                        //po.PODetail = null;
                        //po.ApproveBy = null;
                        //po.ApproveDate = null;
                        //po.UnApproveDate = null;
                        //po.UpApproveBy = null;
                        //po.UpApproveRemark = null;
                        //po.Enable = true;
                        //List<PODetail> details = new List<PODetail>();
                        //PODetail dtls;
                        //foreach (var dtl in item.PODetail.Where(w => w.Enable == true).ToList())
                        //{
                        //    dtls = new PODetail();
                        //    dtls = dtl;
                        //    details.Add(dtls);
                        //    //po.PODetail.Add(dtls);
                        //}
                        //po.PODetail = details;
                        //db.POHeader.Add(po);
                        //db.SaveChanges();
                    }
                    else
                    {
                        MessageBox.Show("ต้องเป็น PO ที่อนุมัติแล้วเท่านั้น " + item.PONo);
                        return;
                    }
                }
                db.SaveChanges();
            }
            Search();
        }