Example #1
0
        public List <string> syncColumnValues(DaftarTable daftar, Int64 syncValue)
        {
            try
            {
                DaftarModelDataContext db = new DaftarModelDataContext(cn);
                var           data        = from a in db.DaftarTables.Where(x => x.Id == daftar.Id) select a;
                List <string> list        = new List <string>();
                list.Add("شناسه های ");
                foreach (var a in data)
                {
                    a.DepositDetail = daftar.DepositDetail;
                    a.CodeBudget    = daftar.CodeBudget;


                    list.Add(a.Id.ToString() + " " + a.DepositOwnerDetail.ToString() + " با موفقیت بروزرسانی شد ");
                }
                db.SubmitChanges();

                return(list);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                List <string> list = new List <string>();
                Reporter      rpt  = new Reporter(list, (int)errorImages.info);
                rpt.Show();
                return(list);
            }
        }
Example #2
0
        private IQueryable <DaftarTable> ConvertElementToQuery(XElement data)
        {
            var d = data.Elements();
            List <DaftarTable> listData = new List <DaftarTable>();

            try
            {
                foreach (var a in d)
                {
                    DaftarTable readXml = new DaftarTable();
                    readXml.AccountType        = a.Element("AccountType").Value;
                    readXml.BillDetailCode     = Convert.ToInt64(a.Element("BillDetailCode").Value);
                    readXml.CityID             = Convert.ToInt64(a.Element("CityID").Value);
                    readXml.CodeBudget         = Convert.ToInt64(a.Element("CodeBudget").Value);
                    readXml.Date               = a.Element("Date").Value;
                    readXml.Deposit            = Convert.ToInt64(a.Element("Deposit").Value);
                    readXml.DepositDetail      = Convert.ToInt64(a.Element("DepositDetail").Value);
                    readXml.DepositOwnerDetail = a.Element("DepositOwnerDetail").Value;
                    readXml.PlaceName          = a.Element("PlaceName").Value;
                    readXml.Refund             = Convert.ToInt64(a.Element("Refund").Value);
                    readXml.RealDate           = Convert.ToInt64(a.Element("RealDate").Value);
                    readXml.Id = Convert.ToInt64(a.Element("Id").Value);
                    listData.Add(readXml);
                }
                return(listData.AsQueryable());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());

                return(listData.AsQueryable());
            }
        }
Example #3
0
        public List <String> addRow(DaftarTable daftar)
        {
            try
            {
                List <string>          report = new List <string>();
                DaftarModelDataContext db     = new DaftarModelDataContext(cn);
                db.DaftarTables.InsertOnSubmit(daftar);
                db.SubmitChanges();
                string person = daftar.Id.ToString() + " " + daftar.DepositOwnerDetail.ToString();
                report.Add(" با موفقیت اضافه گردید" + " " + person);
                return(report);
            }

            //duplicate record
            catch (System.Data.SqlClient.SqlException)
            {
                // MessageBox.Show(ex.ToString());
                // DaftarModelDataContext db = new DaftarModelDataContext(cn);
                List <string> report = new List <string>();
                report.Add(daftar.Id + "" + " شناسه تکراری است . تاریخ یا کد سپرده می بایست متفاوت باشد");
                return(report);
            }

            //catch (Exception ex)
            //{
            //    //MessageBox.Show(ex.Message);
            //    return false;
            //}
        }
Example #4
0
        private void NoteBookDataGridView_SelectionChanged_1(object sender, EventArgs e)
        {
            dataForchanging.Clear();

            foreach (DataGridViewRow row in NoteBookDataGridView.SelectedRows)
            {
                try
                {
                    DaftarTable data = new DaftarTable();

                    data.Id                 = Convert.ToInt64(row.Cells[0].Value);
                    data.Refund             = Convert.ToInt64(row.Cells[1].Value);
                    data.BillDetailCode     = Convert.ToInt64(row.Cells[2].Value);
                    data.Date               = row.Cells[3].Value.ToString();
                    data.PlaceName          = row.Cells[4].Value.ToString();
                    data.AccountType        = row.Cells[5].Value.ToString();
                    data.DepositOwnerDetail = row.Cells[6].Value.ToString();
                    data.DepositDetail      = Convert.ToInt64(row.Cells[7].Value);
                    data.Deposit            = Convert.ToInt64(row.Cells[8].Value);
                    data.CodeBudget         = Convert.ToInt64(row.Cells[9].Value);
                    data.CityID             = Convert.ToInt64(row.Cells[10].Value);
                    data.RealDate           = Convert.ToInt64(row.Cells[11].Value);

                    dataForchanging.Add(data);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Example #5
0
        private void editButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!inputValidation())
                {
                    return;
                }
                Utility        utl       = new Utility();
                SqlManipulator sql       = new SqlManipulator();
                DaftarTable    newDaftar = new DaftarTable();
                if (login.permission)
                {
                    var itm = (ComboboxItem)placeComboBox.SelectedItem;
                    login.cityID = itm.Value;
                }
                else
                {
                    newDaftar.CityID = login.cityID;
                }
                newDaftar.Id = data.Id;

                //var item = (ComboboxItem)placeComboBox.SelectedItem;
                //newDaftar.CityID = item.Value;
                newDaftar.Refund      = Convert.ToInt64(this.refundTextBox.Text);
                newDaftar.AccountType = this.AccountTypeComboBox.SelectedItem.ToString();
                //  newDaftar.BillDetailCode = Convert.ToInt64(this.billDetailCodetextBox.Text);
                newDaftar.CodeBudget = Convert.ToInt64(this.BudgetCodetextBox.Text);
                //newDaftar.Date = this.dateMaskedTextBox.Text;
                newDaftar.PlaceName = placeComboBox.SelectedItem.ToString();
                // newDaftar.RealDate = utl.changeToRealDate(newDaftar.Date);
                newDaftar.Deposit            = Convert.ToInt64(this.DepositTextBox.Text);
                newDaftar.RealDate           = data.RealDate;
                newDaftar.DepositDetail      = Convert.ToInt64(this.DepositDetailtextBox.Text);
                newDaftar.DepositOwnerDetail = this.DepositOwnerDetailTextBox.Text;
                newDaftar.CityID             = data.CityID;

                if (sql.isRestricted(newDaftar, login.permission))
                {
                    MessageBox.Show("دسترسی شما به این تاریخ توسط مدیر سیستم محدود شده است", "خطا",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                ;
                Reporter rpt = new Reporter(sql.update(newDaftar, godmode), (int)errorImages.info);
                rpt.Show();
                form.refreshLastState(lastState, pageNumber, false);
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ورودی های خود را کنترل نمائید", "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                MessageBox.Show(ex.Message);
            }
        }
Example #6
0
 public EditForm(DaftarTable data, MainForm form, LoginInfo login, bool godmode, int pageNumber, LasteStateClass lastState)
 {
     InitializeComponent();
     this.data       = data;
     this.form       = form;
     this.pageNumber = pageNumber;
     this.lastState  = lastState;
     this.godmode    = godmode;
     this.login      = login;
 }
Example #7
0
 public AddEditForm(LoginInfo login, MainForm form, bool addCopiedRow, DaftarTable data, int pageNumber, LasteStateClass lastState)
 {
     InitializeComponent();
     this.login     = login;
     this.form      = form;
     this.data      = data;
     this.lastState = lastState;
     this.AccountTypeComboBox.SelectedIndex = 0;
     this.pageNumber = pageNumber;
     this.copy       = addCopiedRow;
     setPlaceComboBox();
 }
Example #8
0
        public Boolean isRestricted(DaftarTable data, bool permission)
        {
            try {
                if (permission)
                {
                    return(false);
                }
                ValidationDataClassesDataContext db = new ValidationDataClassesDataContext(cn);
                var valid = (from c in db.validationTables.Where(x => x.City == data.CityID && data.RealDate >= x.startDate && data.RealDate <= x.enDate) select c).Any();

                return(valid);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Example #9
0
        public List <string> update(DaftarTable daftar, bool godmode)
        {
            try
            {
                DaftarModelDataContext db = new DaftarModelDataContext(cn);
                var           data        = from a in db.DaftarTables.Where(x => x.Id == daftar.Id) select a;
                List <string> list        = new List <string>();
                list.Add("شناسه های ");
                foreach (var a in data)
                {
                    if ((Math.Abs(Convert.ToInt64(a.Refund))) > 0 && !godmode)
                    {
                        list.Add(a.Id.ToString() + " " + a.DepositOwnerDetail.ToString() + " استرداد شده است! غیر قابل ویرایش می باشد  ");
                    }
                    else
                    {
                        a.Id = daftar.Id;
                        //a.PlaceName = daftar.PlaceName;
                        //a.CityID = daftar.CityID;
                        a.Refund = daftar.Refund;
                        //a.Date = daftar.Date;
                        a.Deposit            = daftar.Deposit;
                        a.DepositDetail      = daftar.DepositDetail;
                        a.DepositOwnerDetail = daftar.DepositOwnerDetail;
                        a.CodeBudget         = daftar.CodeBudget;
                        a.AccountType        = daftar.AccountType;
                        //  a.RealDate = daftar.RealDate;
                        // a.BillDetailCode = daftar.BillDetailCode;
                        list.Add(a.Id.ToString() + " " + a.DepositOwnerDetail.ToString() + " با موفقیت بروزرسانی شد ");
                    }
                }
                db.SubmitChanges();

                return(list);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                List <string> list = new List <string>();
                Reporter      rpt  = new Reporter(list, (int)errorImages.info);
                rpt.Show();
                return(list);
            }
        }
Example #10
0
        public Boolean excelToSqlCopy(IQueryable <Daftarcs> excelQuery, long cityID)
        {
            try
            {
                Utility utl = new Utility();

                DaftarModelDataContext db =
                    new DaftarModelDataContext(cn);
                List <DaftarTable> listDaftar = new List <DaftarTable>();
                foreach (var row in excelQuery)
                {
                    DaftarTable newDaftar = new DaftarTable();
                    newDaftar.DepositOwnerDetail = row.DepositOwnerDetail;
                    newDaftar.PlaceName          = row.PlaceName;
                    newDaftar.AccountType        = row.AccountType;
                    newDaftar.Date           = row.Date;
                    newDaftar.RealDate       = utl.changeToRealDate(newDaftar.Date);
                    newDaftar.BillDetailCode = Convert.ToInt64(row.BillDetailCode);
                    newDaftar.CodeBudget     = Convert.ToInt64(row.CodeBudget);
                    newDaftar.Deposit        = Convert.ToInt64(row.Deposit);
                    newDaftar.DepositDetail  = Convert.ToInt64(row.DepositDetail);
                    newDaftar.Refund         = Convert.ToInt64(row.Refund);

                    newDaftar.Id     = utl.idGenerator(cityID, newDaftar.Date, newDaftar.BillDetailCode);
                    newDaftar.CityID = cityID;
                    listDaftar.Add(newDaftar);
                }
                db.BulkInsertAll(listDaftar);
                excelQuery = null;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Example #11
0
 public MapClassToPersianClass(DaftarTable t)
 {
 }
Example #12
0
 partial void DeleteDaftarTable(DaftarTable instance);
Example #13
0
 partial void UpdateDaftarTable(DaftarTable instance);
Example #14
0
 partial void InsertDaftarTable(DaftarTable instance);
Example #15
0
        public List <string> refundFromFile(IQueryable <Daftarcs> excelQuery, long cityID)
        {
            try
            {
                List <string> report = new List <string>();
                Utility       utl    = new Utility();

                DaftarModelDataContext db =
                    new DaftarModelDataContext(cn);
                List <DaftarTable> listDaftar = new List <DaftarTable>();
                StartEndMonthClass date       = findMinMaxInQuery(excelQuery);
                foreach (var row in excelQuery)
                {
                    DaftarTable newDaftar = new DaftarTable();
                    newDaftar.DepositOwnerDetail = row.DepositOwnerDetail;
                    newDaftar.PlaceName          = row.PlaceName;
                    newDaftar.AccountType        = row.AccountType;
                    newDaftar.Date           = row.Date;
                    newDaftar.RealDate       = utl.changeToRealDate(newDaftar.Date);
                    newDaftar.BillDetailCode = Convert.ToInt64(row.BillDetailCode);
                    newDaftar.CodeBudget     = Convert.ToInt64(row.CodeBudget);
                    newDaftar.Deposit        = Convert.ToInt64(row.Deposit);
                    newDaftar.DepositDetail  = Convert.ToInt64(row.DepositDetail);
                    newDaftar.Refund         = Convert.ToInt64(row.Refund);
                    newDaftar.Id             = utl.idGenerator(cityID, newDaftar.Date, newDaftar.BillDetailCode);
                    newDaftar.CityID         = cityID;
                    listDaftar.Add(newDaftar);
                }
                var query  = listDaftar.AsQueryable();
                var search = (from c in db.DaftarTables.Where(x => x.CityID == cityID && x.RealDate >= date.startDate && x.RealDate <= date.endDate) select c);


                foreach (var b in query)
                {
                    bool refunded = false;
                    foreach (var a in search)
                    {
                        if (a.Id == b.Id)
                        {
                            if (b.Refund != 0 && b.Deposit == 0 && a.Refund == 0)
                            {
                                a.Refund  = a.Deposit;
                                a.Deposit = 0;
                                report.Add(a.DepositOwnerDetail + " " + a.Id + "استرداد شد");
                                refunded = true;
                            }
                        }
                    }

                    if (!refunded)
                    {
                        report.Add(b.DepositOwnerDetail + " " + b.Id + "خطا در استرداد");
                    }
                }
                db.SubmitChanges();
                excelQuery = null;
                return(report);
            }
            catch (Exception ex)
            {
                string        exp    = "خطا";
                List <string> report = new List <string>();
                report.Add(ex.ToString());
                report.Add(exp);
                return(report);
            }
        }