コード例 #1
0
        private void ResetForm()
        {
            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;
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        private void StoreFrontAddForm_Load(object sender, EventArgs e)
        {
            textBoxDate.Text     = Library.ConvertDateToThaiDate(DateTime.Now);
            textBoxUserId.Text   = Singleton.SingletonAuthen.Instance().Id;
            textBoxUserName.Text = Singleton.SingletonAuthen.Instance().Name;
            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;
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (TbbudgetYear.Text == "")
                {
                    MessageBox.Show("กรุณากรอก ปีงบประมาณ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DialogResult dialogResult = MessageBox.Show("ยืนยันทำรายการใช่หรือไม่", "Some Title", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    DateTime dat = Library.DateTimeServer();
                    using (SSLsEntities db = new SSLsEntities())
                    {
                        var ds = db.BudgetYear.Where(w => w.Enable == true).ToList();

                        if (ds.Where(w => w.StartDate <= dateTimePicker1.Value & w.EndDate >= dateTimePicker1.Value).ToList().Count > 0)
                        {
                            MessageBox.Show("ไม่สามารถใช้วันที่เริ่มต้นนี้ได้ เนื่องจากมีอยุ่ในงบประมาณอื่นเเล้ว", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        if (ds.Where(w => w.StartDate <= dateTimePicker2.Value & w.EndDate >= dateTimePicker2.Value).ToList().Count > 0)
                        {
                            MessageBox.Show("ไม่สามารถใช้วันที่สิ้นสุดนี้ได้ เนื่องจากมีอยุ่ในงบประมาณอื่นเเล้ว", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        if (ds.Where(w => w.ThaiYear == TbbudgetYear.Text.Trim()).ToList().Count > 0)
                        {
                            MessageBox.Show("ปีงบประมาณซ้ำ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }


                        BudgetYear by = new BudgetYear();
                        by.Name        = TbbudgetYear.Text.Trim();
                        by.ThaiYear    = TbbudgetYear.Text.Trim();
                        by.Description = (TbDes.Text == "" ? null: TbDes.Text);
                        by.EngYear     = (int.Parse(TbbudgetYear.Text.Trim()) + 543).ToString();
                        by.StartDate   = dateTimePicker1.Value;
                        by.EndDate     = dateTimePicker2.Value;
                        by.CodeYear    = TbbudgetYear.Text.Trim().Substring(2, 2);
                        by.IsCurrent   = false;
                        by.Enable      = true;
                        by.CreateDate  = dat;
                        by.CreateBy    = Singleton.SingletonAuthen.Instance().Id;
                        by.UpdateDate  = dat;
                        by.UpdateBy    = Singleton.SingletonAuthen.Instance().Id;
                        db.BudgetYear.Add(by);
                        db.SaveChanges();
                    }
                    MessageBox.Show("เพิ่มข้อมูลสำเร็๋จ", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Singleton.SingletonBudgetYearNew.SetInstance();
                    comboBox1_SelectedIndexChanged(sender, e);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
        private void SaveCommit()
        {
            try
            {
                CNWarehouse cnw = new CNWarehouse();

                cnw.Enable        = true;
                cnw.Description   = textBoxDesc.Text;
                cnw.CreateDate    = DateTime.Now;
                cnw.CreateBy      = Singleton.SingletonAuthen.Instance().Id;
                cnw.UpdateDate    = DateTime.Now;
                cnw.UpdateBy      = Singleton.SingletonAuthen.Instance().Id;
                cnw.FKWasteReason = _WasteReason;
                decimal qtyPiece = 0;
                List <CNWarehouseDetails> details = new List <CNWarehouseDetails>();
                CNWarehouseDetails        detail;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    var code = dataGridView1.Rows[i].Cells[colCode].Value;
                    if (code == null)
                    {
                        continue;
                    }
                    detail                  = new CNWarehouseDetails();
                    qtyPiece               += decimal.Parse(dataGridView1.Rows[i].Cells[colQty].Value.ToString()) * decimal.Parse(dataGridView1.Rows[i].Cells[colPZ].Value.ToString());
                    detail.Enable           = true;
                    detail.Description      = dataGridView1.Rows[i].Cells[colDescription].Value.ToString();
                    detail.CreateDate       = DateTime.Now;
                    detail.CreateBy         = Singleton.SingletonAuthen.Instance().Id;
                    detail.UpdateDate       = DateTime.Now;
                    detail.UpdateBy         = Singleton.SingletonAuthen.Instance().Id;
                    detail.FKProductDetails = int.Parse(dataGridView1.Rows[i].Cells[colId].Value.ToString());
                    detail.Qty              = decimal.Parse(dataGridView1.Rows[i].Cells[colQty].Value.ToString());
                    detail.PricePerUnit     = decimal.Parse(dataGridView1.Rows[i].Cells[colCostPerUnit].Value.ToString());
                    detail.BeforeVat        = decimal.Parse(dataGridView1.Rows[i].Cells[colCostPerUnit].Value.ToString()) * detail.Qty;
                    detail.Vat              = 0;
                    detail.TotalPrice       = detail.BeforeVat + detail.Vat;
                    details.Add(detail);
                    //if (i >= dataGridView1.Rows.Count - 2) break;
                }
                cnw.FKVendor           = _VendorId;
                cnw.DocDate            = DateTime.Now;
                cnw.DocRefer           = textBoxDocRefer.Text;
                cnw.TotalQty           = qtyPiece;
                cnw.TotalQtyUnit       = decimal.Parse(textBoxQtyUnit.Text);
                cnw.TotalUnVat         = decimal.Parse(textBoxTotalUnVat.Text);
                cnw.TotalBeforeVat     = decimal.Parse(textBoxTotalBeforeVat.Text);
                cnw.TotalVat           = decimal.Parse(textBoxTotalVat.Text);
                cnw.TotalBalance       = decimal.Parse(textBoxTotalBalance.Text);
                cnw.CNWarehouseDetails = details;

                using (SSLsEntities db = new SSLsEntities())
                {
                    int        currentYear  = DateTime.Now.Year;
                    int        currentMonth = DateTime.Now.Month;
                    var        getCNCode    = db.CNWarehouse.Where(w => w.CreateDate.Year == currentYear && w.CreateDate.Month == currentMonth).Count() + 1;
                    BudgetYear budget       = Singleton.SingletonThisBudgetYear.Instance().ThisYear;
                    //Branch branch = Singleton.SingletonP
                    var code = MyConstant.PrefixForGenerateCode.GoodsReturnCN + "" + budget.CodeYear + DateTime.Now.ToString("MM") + Library.GenerateCodeFormCount(getCNCode, 4);
                    cnw.Code = code;
                    db.CNWarehouse.Add(cnw);
                    db.SaveChanges();
                    // ManageStock Wms
                    //Library.MakeValueForUpdateStockWms(details);
                    MessageBox.Show("บันทึกเรียบร้อย " + cnw.Code);

                    frmMainReport mr = new frmMainReport(this, code);
                    mr.Show();

                    ResetForm();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("พบข้อมผิดพลาด");
            }
        }