Пример #1
0
        private void SaveTrans(TMsg msg)
        {
            string pesan     = string.Empty;
            bool?  isSuccess = null;

            //MessageBox.Show(msg.MsgText);
            //MessageBox.Show(msg.MsgFrom);
            try
            {
                _tSalesRepository.DbContext.BeginTransaction();

                //split string
                SaveTransHelper hlp = new SaveTransHelper(_tSalesRepository, _tSalesDetRepository, _mGameRepository, _mAgentRepository, _tMsgRepository);
                hlp.SaveToTrans(msg, msg.MsgText, dtSalesDate.Value);

                _tSalesRepository.DbContext.CommitTransaction();
                isSuccess = true;
                pesan     = "\nBerhasil.";
            }
            catch (Exception ex)
            {
                _tSalesRepository.DbContext.RollbackTransaction();
                isSuccess = false;
                pesan     = "\nGagal.\n" + ex.GetBaseException().Message;
                //throw ex;
            }
            finally
            {
                if (isSuccess.HasValue)
                {
                    _tSalesRepository.DbContext.BeginTransaction();
                    //update msg status
                    msg.MsgStatus    = string.Format("Read|{0}", isSuccess.Value.ToString());
                    msg.DataStatus   = EnumDataStatus.Updated.ToString();
                    msg.ModifiedBy   = Environment.UserName;
                    msg.ModifiedDate = DateTime.Now;
                    _tMsgRepository.Update(msg);
                    _tSalesRepository.DbContext.CommitTransaction();

                    string txt          = msg.MsgText;
                    string sender       = "+" + msg.MsgFrom;
                    bool   replySuccess = SendMessage(txt, sender, pesan);
                }
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                _tSalesRepository.DbContext.BeginTransaction();
                //split string
                SaveTransHelper hlp = new SaveTransHelper(_tSalesRepository, _tSalesDetRepository, _mGameRepository, _mAgentRepository, _tMsgRepository);
                hlp.SaveToTrans(null, txtManual.Text, dtSalesDateManual.Value);

                _tSalesRepository.DbContext.CommitTransaction();
                MessageBox.Show("Input manual Berhasil disimpan.");
                txtManual.ResetText();
            }
            catch (Exception ex)
            {
                _tSalesRepository.DbContext.RollbackTransaction();
                MessageBox.Show("Input manual gagal disimpan. Error : " + ex.GetBaseException().Message);
                //throw;
            }
        }