Esempio n. 1
0
        public List <SaleRate> selectSRAll()
        {
            List <SaleRate> lsr = new List <SaleRate>();
            DataTable       dt1 = selectAll();

            if (dt1.Rows.Count > 0)
            {
                for (int i = 0; i < dt1.Rows.Count; i++)
                {
                    SaleRate item = new SaleRate();
                    item.Id          = dt1.Rows[i][sr.Id].ToString();
                    item.Description = dt1.Rows[i][sr.Description].ToString();
                    item.rec         = dt1.Rows[i][sr.rec].ToString();
                    item.pay         = dt1.Rows[i][sr.pay].ToString();
                    item.limit1      = dt1.Rows[i][sr.limit1].ToString();
                    item.discount    = dt1.Rows[i][sr.discount].ToString();
                    item.Active      = dt1.Rows[i][sr.Active].ToString();
                    item.thooId      = dt1.Rows[i][sr.thooId].ToString();
                    item.SaleId      = dt1.Rows[i][sr.SaleId].ToString();
                    item.RateId      = dt1.Rows[i][sr.RateId].ToString();
                    lsr.Add(item);
                }
            }
            return(lsr);
        }
Esempio n. 2
0
        public String getSalePercent(String yearId, String monthId, String periodId, String saleId)
        {
            String    num = "";
            DataTable dt1 = lotdb.selectBySale(yearId, monthId, periodId, saleId);
            Double    up = 0, down = 0, tod = 0, amtUp = 0, amtTod = 0, amtDown = 0, amt = 0;
            Sale      s = new Sale();

            if (dt1.Rows.Count > 0)
            {
                s = getSalebyListS(saleId);
                //DataTable dtRate = ratedb.selectAll();
                for (int i = 0; i < dt1.Rows.Count; i++)
                {
                    SaleRate sr = new SaleRate();
                    //DataTable dtSR = srdb.selectBySale(dt.Rows[i][lotdb.lot.saleId].ToString());
                    num     = dt1.Rows[i][lotdb.lot.number].ToString();
                    up      = Double.Parse(cf.NumberNull(dt1.Rows[i][lotdb.lot.up]));
                    down    = Double.Parse(cf.NumberNull(dt1.Rows[i][lotdb.lot.down]));
                    tod     = Double.Parse(cf.NumberNull(dt1.Rows[i][lotdb.lot.tod]));
                    amtUp   = 0;
                    amtDown = 0;
                    amtTod  = 0;
                    if (s.statusDiscount.Equals("1"))
                    {
                        if (num.Length == 1)
                        {
                            sr      = getSaleRatebyListSR(lsr, saleId, "up");
                            amtUp   = (up * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                            sr      = getSaleRatebyListSR(lsr, saleId, "down");
                            amtDown = (down * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                        }
                        else if (num.Length == 2)
                        {
                            sr      = getSaleRatebyListSR(lsr, saleId, "2up");
                            amtUp   = (up * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                            sr      = getSaleRatebyListSR(lsr, saleId, "2down");
                            amtDown = (down * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                            sr      = getSaleRatebyListSR(lsr, saleId, "2tod");
                            amtTod  = (tod * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                        }
                        else if (num.Length == 3)
                        {
                            sr      = getSaleRatebyListSR(lsr, saleId, "3up");
                            amtUp   = (up * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                            sr      = getSaleRatebyListSR(lsr, saleId, "3down");
                            amtDown = (down * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                            sr      = getSaleRatebyListSR(lsr, saleId, "3tod");
                            amtTod  = (tod * Double.Parse(cf.NumberNull(sr.discount))) / 100;
                        }
                    }
                    else
                    {
                    }

                    amt += amtUp + amtDown + amtTod;
                }
            }
            return(amt.ToString());
        }
 public bool Insert(SaleRate rate)
 {
     try
     {
         db.SaleRates.Add(rate);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 4
0
 private SaleRate setData(SaleRate item, DataTable dt, int row)
 {
     item.Id          = dt.Rows[row][sr.Id].ToString();
     item.Description = dt.Rows[row][sr.Description].ToString();
     item.rec         = dt.Rows[row][sr.rec].ToString();
     item.pay         = dt.Rows[row][sr.pay].ToString();
     item.limit1      = dt.Rows[row][sr.limit1].ToString();
     item.discount    = dt.Rows[row][sr.discount].ToString();
     item.Active      = dt.Rows[row][sr.Active].ToString();
     item.thooId      = dt.Rows[row][sr.thooId].ToString();
     item.SaleId      = dt.Rows[row][sr.SaleId].ToString();
     item.RateId      = dt.Rows[row][sr.RateId].ToString();
     return(item);
 }
Esempio n. 5
0
        public SaleRate selectByPk(String saleId)
        {
            SaleRate  item = new SaleRate();
            String    sql  = "";
            DataTable dt   = new DataTable();

            sql = "Select * From " + sr.table + " Where " + sr.pkField + "='" + saleId + "'";
            dt  = conn.selectData(sql);
            if (dt.Rows.Count > 0)
            {
                item = setData(item, dt);
            }
            return(item);
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtSaleName.Text.Equals(""))
            {
                MessageBox.Show("aaa", "aaa");
                return;
            }
            if (txtSaleCode.Text.Equals(""))
            {
                MessageBox.Show("aaa", "aaa");
                return;
            }
            if (txtSaleId.Text.Equals(""))
            {
                s = lc.saledb.selectByCode(txtSaleCode.Text);
                if (!s.Code.Equals(""))
                {
                    MessageBox.Show("รหัสที่สร้างใหม่ มีคนใช้แล้ว\n รหัส" + s.Code + " ชื่อ " + s.Name, "รหัสซ้ำ");
                    return;
                }
            }
            s = getControl();
            if (lc.saveSale(s).Length >= 1)
            {
                if (chkDiscount.Checked)
                {
                    for (int i = 0; i < dgvRate.RowCount; i++)
                    {
                        SaleRate sr = new SaleRate();
                        sr.SaleId = txtSaleId.Text;
                        if (dgvRate[colRDescription, i].Value != null)
                        {
                            sr.Description = dgvRate[colRDescription, i].Value.ToString();
                            sr.rec         = dgvRate[colRRec, i].Value.ToString();
                            sr.limit1      = dgvRate[colRLimit, i].Value.ToString();
                            sr.discount    = dgvRate[colRDiscount, i].Value.ToString();
                            sr.RateId      = dgvRate[colRId, i].Value.ToString();
                            sr.Id          = dgvRate[colSRId, i].Value.ToString();
                            sr.Active      = "1";

                            lc.srdb.insertSaleRate(sr);
                        }
                    }
                }
                MessageBox.Show("บันทึกข้อมูล เรียบร้อย", "บันทึกข้อมูล");
                this.Dispose();
                //this.Hide();
            }
        }
Esempio n. 7
0
        public String insertSaleRate(SaleRate p)
        {
            SaleRate item = new SaleRate();
            String   chk  = "";

            item = selectByPk(p.Id);
            if (item.Id == "")
            {
                chk = insert(p);
            }
            else
            {
                chk = update(p);
            }
            return(chk);
        }
Esempio n. 8
0
        private String insert(SaleRate p)
        {
            String sql = "", chk = "";

            if (p.Id.Equals(""))
            {
                p.Id = p.getGenID();
            }
            p.Description = p.Description.Replace("''", "'");
            if (p.pay.Equals(""))
            {
                p.pay = "0";
            }
            if (p.limit1.Equals(""))
            {
                p.limit1 = "0";
            }
            if (p.discount.Equals(""))
            {
                p.discount = "0";
            }
            if (p.rec.Equals(""))
            {
                p.rec = "1";
            }
            //p.Remark = p.Remark.Replace("''", "'");
            sql = "Insert Into " + sr.table + " (" + sr.pkField + "," + sr.Description + "," + sr.rec + "," +
                  sr.pay + "," + sr.limit1 + "," + sr.discount + "," +
                  sr.thooId + "," + sr.Active + "," + sr.RateId + "," + sr.SaleId + ") " +
                  "Values('" + p.Id + "','" + p.Description + "'," + p.rec + "," +
                  p.pay + "," + p.limit1 + "," + p.discount + ",'" +
                  p.thooId + "','" + p.Active + "','" + p.RateId + "','" + p.SaleId + "')";
            try
            {
                chk = conn.ExecuteNonQuery(sql);
                chk = p.Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.ToString(), "insert SaleRate");
            }
            finally
            {
            }
            return(chk);
        }
Esempio n. 9
0
        public SaleRate getSaleRatebyListSR(List <SaleRate> lsr, String saleId, String rateId)
        {
            SaleRate item = new SaleRate();

            for (int i = 0; i < lsr.Count; i++)
            {
                item = new SaleRate();
                item = lsr[i];
                if (item.SaleId.Equals(saleId))
                {
                    if (item.RateId.Equals(rateId))
                    {
                        return(item);
                    }
                }
            }
            return(item);
        }
Esempio n. 10
0
        private void initConfig()
        {
            sr = new SaleRate();

            sr.Id          = "sale_rate_id";
            sr.SaleId      = "sale_id";
            sr.RateId      = "rate_id";
            sr.Description = "sale_rate_description";
            sr.rec         = "rec";
            sr.pay         = "pay";
            sr.limit1      = "limit1";
            sr.discount    = "discount";
            sr.Active      = "sale_rate_active";
            sr.thooId      = "thoo_id";
            sr.sited       = "";
            sr.table       = "b_sale_rate";
            sr.pkField     = "sale_rate_id";
        }
Esempio n. 11
0
        private String update(SaleRate p)
        {
            String sql = "", chk = "";

            p.Description = p.Description.Replace("''", "'");
            if (p.pay.Equals(""))
            {
                p.pay = "0";
            }
            if (p.limit1.Equals(""))
            {
                p.limit1 = "0";
            }
            if (p.discount.Equals(""))
            {
                p.discount = "0";
            }
            if (p.rec.Equals(""))
            {
                p.rec = "1";
            }
            sql = "Update " + sr.table + " Set " + sr.Description + "='" + p.Description + "', " +
                  sr.rec + "=" + p.rec.Replace(",", "") + ", " +
                  sr.pay + "=" + p.pay.Replace(",", "") + ", " +
                  sr.limit1 + "=" + p.limit1.Replace(",", "") + ", " +
                  sr.discount + "=" + p.discount.Replace(",", "") + ", " +
                  sr.thooId + "='" + p.thooId + "', " +
                  sr.RateId + "='" + p.RateId + "', " +
                  sr.SaleId + "='" + p.SaleId + "' " +
                  "Where " + sr.pkField + "='" + p.Id + "'";
            try
            {
                chk = conn.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.ToString(), "update Rate");
            }
            finally
            {
            }
            return(chk);
        }
Esempio n. 12
0
 public bool UpdateStatusMerchant(long id)
 {
     try
     {
         var user = GetInfoByID(id);
         user.StatusShop = true;
         user.Level      = 2;
         var rate = new SaleRate();
         rate.ID   = id;
         rate.Rate = 0;
         var salerate = new SaleRateDAO().Insert(rate);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 13
0
        private void initConfig()
        {
            iniFile = new IniFile(Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini");
            initC   = new InitConfig();
            //regE = new RegEdit();
            //MessageBox.Show("aaa " + Environment.CurrentDirectory + "\\" + Application.ProductName + ".ini", "LottoryControl StatusServer" + initC.StatusServer.ToLower());
            GetConfig();
            //MessageBox.Show("bbb", "LottoryControl");
            cf = new Config1();
            //MessageBox.Show("ccc", "LottoryControl");
            conn   = new ConnectDB(initC);
            ratedb = new RateDB(conn);
            saledb = new SaleDB(conn);
            sfdb   = new StaffDB(conn);
            thodb  = new ThooDB(conn);
            lotdb  = new LottoDB(conn);
            rwdb   = new RewardDB(conn);
            fldb   = new FlockDB(conn);
            srdb   = new SaleRateDB(conn);
            cudb   = new CustomerDB(conn);
            imgdb  = new ImageDB(conn);
            nldb   = new NumberLimitDB(conn);
            //MessageBox.Show("ddd", "LottoryControl");
            rate  = new Rate();
            sale  = new Sale();
            staff = new Staff();
            tho   = new Thoo();
            lot   = new Lotto();
            rw    = new Reward();
            fl    = new FLock();
            sr    = new SaleRate();
            cu    = new Customer();
            img   = new Image1();
            nl    = new NumberLimit();

            r2Down = new Rate();
            r2Tod  = new Rate();
            r2Up   = new Rate();
            r3Up   = new Rate();
            r3Tod  = new Rate();
            r3Down = new Rate();
            rUp    = new Rate();
            rDown  = new Rate();
            //MessageBox.Show("bbb", "LottoryControl");
            rUp    = ratedb.selectByPk("up");
            rDown  = ratedb.selectByPk("down");
            r3Up   = ratedb.selectByPk("3up");
            r3Tod  = ratedb.selectByPk("3tod");
            r3Down = ratedb.selectByPk("3down");
            r2Down = ratedb.selectByPk("2down");
            r2Up   = ratedb.selectByPk("2up");
            lTho   = thodb.setData();
            setThoColor();
            lsr = srdb.selectSRAll();
            ls  = saledb.selectSAll();
            lnl = selectByNumberLimit();
            //cboThoo = new ComboBox();
            cbosf = new ComboBox();
            //cboSale = new ComboBox();
            //cboThoo = thodb.getCboThoo(cboThoo);
            cbosf = sfdb.getCboStaff(cbosf);
            //cboSale = saledb.getCboSale(cboSale);
        }
Esempio n. 14
0
        public string ToSql()
        {
            var sql = new StringWriter();

            sql.WriteLine("MERGE ExchangeRate AS Target");
            sql.WriteLine("USING (SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}) As Source (BankId, DayOfYear, Year, Date, Month, MonthName, DayName, UtcLastUpdateOn, BuyRate, SaleRate)", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql(), Date.ToSql(), Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            sql.WriteLine("ON Target.BankId = {0} And Target.DayOfYear = {1} And Target.Year = {2}", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql());
            sql.WriteLine("WHEN MATCHED THEN");
            sql.WriteLine(" UPDATE SET Month = {0}, MonthName = {1}, DayName = {2}, UtcLastUpdateOn = {3}, BuyRate = {4}, SaleRate = {5}", Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            sql.WriteLine("WHEN NOT MATCHED THEN");
            sql.WriteLine(" INSERT (BankId, DayOfYear, Year, Date, Month, MonthName, DayName, UtcLastUpdateOn, BuyRate, SaleRate)");
            sql.WriteLine(" VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9});", BankId.ToSql(), DayOfYear.ToSql(), Year.ToSql(), Date.ToSql(), Month.ToSql(), MonthName.ToSql(), DayName.ToSql(), UtcLastUpdateOn.ToSql(), BuyRate.ToSql(), SaleRate.ToSql());
            return(sql.ToString());
        }