Ejemplo n.º 1
0
        public bool DeleteRate(RateModel model, string id)
        {
            try
            {
                ExecuteCommand(cn =>
                {
                    MySqlCommand cmd = new MySqlCommand(@"update tblrate set deleted=1
                            where rtGUID=@id", cn);
                    cmd.Parameters.AddWithValue("id", id);
                    rst = cmd.ExecuteNonQuery();
                });
                if (rst == 1)
                    return true;
                else
                    return false;

            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 2
0
        private void btn_inset_Rate_Click(object sender, EventArgs e)
        {
            string dateRate;
            dateRate = cbo_date.Text;
            RateModel RM;
            try
            {
                if (layerRate.GetValRate(DateTime.Parse(cbo_date.Text), cbo_Curr_cd.SelectedValue.ToString()))
                {
                    var exceptionMessage = "Rate Currency already exist";
                    // clsWin.ClearWindowsObJect(panelEx1);
                    clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");
                    cbo_date.Focus();
                    return;
                }
                RM = new RateModel()
                {
                    rtGUID = Guid.NewGuid().ToString(),
                    rtDate = DateTime.Parse(cbo_date.Text),
                    CurrGUID =  cbo_Curr_cd.SelectedValue.ToString(),
                    rtValue = double.Parse(txt_rate_value.Text.ToString()),
                    Comp = clsWin.GetComputerName(),
                    UserName = _frmMain.activeuser,
                    LastUpdate = DateTime.Now
                };
                layerRate.InSertRate(RM);
                Btn_refresh.PerformClick();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                    .SelectMany(x => x.ValidationErrors)
                    .Select(x => x.ErrorMessage);
                var exceptionMessage = string.Concat(errorMessages);
                clsWin.ClearWindowsObJect(panelEx1);
                clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");

                Btn_refresh.PerformClick();
            }
        }
Ejemplo n.º 3
0
        public bool UpdatetRate(RateModel model, string id)
        {
            try
            {
                ExecuteCommand(cn =>
                {
                    MySqlCommand cmd = new MySqlCommand(@"update tblrate set rtDate=@rtDate,
                            CurrGUID=@CurrGUID,rtValue=@rtValue,Comp=@Comp,UserName=@username
                            where uGUID=@id", cn);
                    cmd.Parameters.AddWithValue("id", id);
                    cmd.Parameters.AddWithValue("@rtDate", model.rtDate);
                    cmd.Parameters.AddWithValue("@CurrGUID", model.CurrGUID);
                    cmd.Parameters.AddWithValue("@rtValue", model.rtValue);
                    cmd.Parameters.AddWithValue("@Comp", model.Comp);
                    cmd.Parameters.AddWithValue("@username", model.UserName);
                    rst = cmd.ExecuteNonQuery();
                });
                if (rst == 1)
                    return true;
                else
                    return false;

            }
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 4
0
        public bool InSertRate(RateModel model)
        {
            try
            {
                ExecuteCommand(cn =>
                {
                    MySqlCommand cmd = new MySqlCommand(@"Insert Into tblrate (rtGUID,rtDate,CurrGUID,rtValue,Comp,UserName,LastUpdate)
                            values(@rtGUID,@rtDate,@CurrGUID,@rtValue,@Comp,@username,@LastUpdate)", cn);
                    cmd.Parameters.AddWithValue("rtGUID", model.rtGUID);
                    cmd.Parameters.AddWithValue("@rtDate", model.rtDate);
                    cmd.Parameters.AddWithValue("@CurrGUID", model.CurrGUID);
                    cmd.Parameters.AddWithValue("@rtValue", model.rtValue);
                    cmd.Parameters.AddWithValue("@Comp", model.Comp);
                    cmd.Parameters.AddWithValue("@username", model.UserName);
                    cmd.Parameters.AddWithValue("@LastUpdate", model.LastUpdate);
                    rst = cmd.ExecuteNonQuery();

                });
                if (rst == 1)
                    return true;
                else
                    return false;

            }
            catch (Exception)
            {

                throw;
            }
        }