void gaapTable_OnDeleteCommand(string id) { using (var da = new HesapPlaniTableAdapter()) { try { int? error = null; da.DeleteQuery(id, ref error); if (error == -1) { Master.ShowMessage("Ana hesaplar silinemez", PageMaster.MsgType.Error); } } catch (SqlException error) { if (error.Number == 547) { Master.ShowMessage("Alt hesabı bulunan hasaplar silinemez", PageMaster.MsgType.Error); } else { throw error; } } } }
protected void Page_PreRender(object sender, EventArgs e) { using (var da = new HesapPlaniTableAdapter()) { var dt = da.GetData(); var ds = (from row in dt select new Dictionary<string, object> { {"Kod",row.Kod}, {"HesapAdi",row.HesapAdi}, {"Tipi",row.Tipi}, {"Borç",0}, {"Alacak",0}, {"Borç Bakiye",0}, {"Alacak Bakiye",0} }); if (IsPostBack) { var aClass = filter_accountClass.Value; if (aClass != null && aClass != "all") { ds = ds.Where(row => row["Kod"].ToString().StartsWith(aClass)); } ds = ds.Where(row => accountType.Items.FindByValue(row["Tipi"].ToString()).Selected); } gaapTable.DataSource = ds.ToList(); gaapTable.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { stockPictures = new DataSet.StokKartResimDataTable(); if (IsPostBack) { stockCode = Request.Params["StockQueryCode"]; using (var daAccountPlan = new HesapPlaniTableAdapter()) using (var daStock = new stokKartTableAdapter()) using (var daStockPicture = new StokKartResimTableAdapter()) { stocks = daStock.GetData(); if (Request.Params["GetStock"] != null) { stock = stocks.FirstOrDefault(s => s.stokKod == stockCode); if (stock != null) { purchaseLibraName = daAccountPlan.GetDataByKod(stock.AlısMizanKodu)[0].HesapAdi; sellingLibraName = daAccountPlan.GetDataByKod(stock.SatısMizanKodu)[0].HesapAdi; stockPictures = daStockPicture.GetDataByStokKod(stockCode); } else { Master.ShowMessage(String.Format("{0} nolu stok kartı bulunmuyor.", stockCode), PageMaster.MsgType.Error); } } else if(Request.Params["SaveStock"] != null) { var stockName = Request.Params["StockName"]; var barcode = Request.Params["Barcode"]; var type = Request.Params["Type"]; var group = Request.Params["Group"]; var uniqueCode1 = Request.Params["UniqueCode1"]; var uniqueCode2 = Request.Params["UniqueCode2"]; var currency = Request.Params["Currency"]; var unit = Request.Params["Unit"]; var purchasePrice = Request.Params["PurchasePrice"].trimMoney().getMoney(); var salePrice = Request.Params["SalePrice"].trimMoney().getMoney(); var costPrice = Request.Params["CostPrice"].trimMoney().getMoney(); var minStock = Int32.Parse(Request.Params["MinStock"]); var maxStock = Int32.Parse(Request.Params["MaxStock"]); var taxRate = Int32.Parse(Request.Params["TaxRate"]); var user = Request.Params["User"]; var stockCheckDate = Request.Params["StockCheckDate"]; var stockCheckAmount = Request.Params["StockCheckAmount"]; var stockSaveDate = ""; var description = Request.Params["Description"]; var webCategory = Request.Params["WebCategory"]; var webOpen = Request.Params["WebOpen"] != null; var purchaseLibraCode = Request.Params["PurchaseLibraCode"]; var saleLibraCode = Request.Params["SaleLibraCode"]; var parentCode = stockCode.Substring(0, stockCode.LastIndexOf('.')); var webPriceOpen = Request.Params["WebPriceOpen"] != null; int? error = null; if (daStock.GetDataByStokKod(stockCode).Count > 0) { daStock.UpdateQuery(stockCode, 0, stockName, barcode, type, group, uniqueCode1, uniqueCode2, unit, purchasePrice, costPrice, 0, salePrice, maxStock, minStock, taxRate, user, null, null, null, description, webCategory, webOpen, purchaseLibraCode, saleLibraCode, parentCode, webPriceOpen, ref error); } else { daStock.InsertQuery(stockCode, stockName, barcode, type, group, uniqueCode1, uniqueCode2, unit, purchasePrice, costPrice, 0, salePrice, maxStock, minStock, taxRate, user, null, null, null, description, webCategory, webOpen, purchaseLibraCode, saleLibraCode, parentCode,webPriceOpen, ref error); } if (error == null) { Master.ShowMessage("Kaydetme işlemi tamamlandı.", PageMaster.MsgType.Info); stock = daStock.GetDataByStokKod(stockCode)[0]; stockPictures = daStockPicture.GetDataByStokKod(stockCode); purchaseLibraName = daAccountPlan.GetDataByKod(stock.AlısMizanKodu)[0].HesapAdi; sellingLibraName = daAccountPlan.GetDataByKod(stock.SatısMizanKodu)[0].HesapAdi; } else { Master.ShowMessage("Kaydetme işlemi sırasında hata oluştu: " + error,PageMaster.MsgType.Error); } } else if (Request.Params["DeleteStock"] != null) { var pictures = daStockPicture.GetDataByStokKod(stockCode); foreach (var picture in pictures) { var imgUrl = MapPath(ImgLocation + "/" + picture.ResimUrl); File.Delete(imgUrl); } daStockPicture.DeleteByStockCode(stockCode); daStock.DeleteQuery(stockCode); Master.ShowMessage("Silme işlemi tamamlandı.", PageMaster.MsgType.Info); stockCode = ""; } } } }
protected void Page_Load(object sender, EventArgs e) { accountCode = Request.Params["AccountCode"]; using (var da = new CariKartTableAdapter()) { accounts = da.GetData(); if (IsPostBack) { if (Request.Params["GetAccount"] != null) { accountCode = Request.Params["AccountQueryCode"]; var dt = da.GetDataByCariKod(accountCode); if (dt.Count > 0) { account = dt[0]; //TODO } else { Master.ShowMessage(String.Format("{0} numaralı cari hesap bulunmuyor.", accountCode), PageMaster.MsgType.Info); } } else if (Request.Params["SaveAccount"] != null) { var parentCode = accountCode.Substring(0, accountCode.LastIndexOf('.')); var accountName = Request.Params["AccountName"]; var officer = Request.Params["Officer"]; var adress = Request.Params["Adress"]; var taxOffice = Request.Params["TaxOffice"]; var taxNo = Request.Params["TaxNo"]; var phone = Request.Params["Phone"]; var fax = Request.Params["Fax"]; var group = Request.Params["Group"]; var currency = Request.Params["Currency"]; var riskLimit = Decimal.Parse(Request.Params["RiskLimit"].trimMoney()); var email = Request.Params["Email"]; var web = Request.Params["Web"]; var ackMail = Request.Params["AcknowledgementEmail"] != null; var termRate = Int32.Parse(Request.Params["TermRate"]); var termDays = Int32.Parse(Request.Params["TermDays"]); var libraCode = Request.Params["LibraCode"]; DateTime? agrDate = null; DateTime temp; if (DateTime.TryParseExact(Request.Params["Date"], "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out temp)) agrDate = temp; var agrTotal = Request.Params["Total"].trimMoney().getMoney(); var agrNet = Request.Params["Net"]; var cityCode = Int32.Parse(Request.Params["City"]); var district = Request.Params["District"]; var type = Int32.Parse(Request.Params["Type"]); var buyer = type == 1 || type == 3; var seller = type == 2 || type == 3; var uniqueCode = (String)Request.Params["UniqueCode"]; uniqueCode = uniqueCode != "" ? uniqueCode : null; var checkLimit = Decimal.Parse(Request.Params["CheckLimit"].trimMoney()); var user = Request.Params["User"]; user = user != "" ? user : null; var discountRate = Int32.Parse(Request.Params["DiscountRate"]); int? error = null; if (Request.Params["ExistingAccount"] == "true") { try { da.UpdateQuery(accountCode, parentCode, accountName, group, riskLimit, currency, agrDate, agrTotal, agrNet, officer, adress, taxOffice, taxNo, phone , fax, email, web, ackMail, termRate, termDays, libraCode, cityCode, district,buyer,seller,checkLimit,uniqueCode,user,discountRate, ref error); } catch (System.Data.SqlClient.SqlException exception) { if (exception.Number == 547) { error = -99; } else { throw; } } if (error == -1) { Master.ShowMessage("Mizan kodu olarak kullanılan hesap kodlarının \"Alt\" olarak atanmış olması gerekir", PageMaster.MsgType.Error); } else if(error == -2) { Master.ShowMessage(String.Format("Girilen özel kodun ({0}) tekrarı başka bir cari kartta bulunuyor.",uniqueCode), PageMaster.MsgType.Error); } else if (error == -99) { Master.ShowMessage(String.Format("Geçersiz mizan kodu. ({0})", libraCode), PageMaster.MsgType.Error); } else { Master.ShowMessage(string.Format("{0} ({1}) cari hesap kartı güncellendi.", accountName, accountCode), PageMaster.MsgType.Info); } } else { //using (var daHesapPlani = new HesapPlaniTableAdapter()) //{ // if (daHesapPlani.GetDataByKod(accountCode).Count > 0) // { // Master.ShowMessage(String.Format("({0} nolu hesap, hesap planında mevcut.", accountCode), PageMaster.MsgType.Error); // return; // } // else // { // var parentCode = accountCode.Substring(0, accountCode.LastIndexOf('.')); // int? error = null; // daHesapPlani.InsertMethod(accountCode, parentCode, accountName, "Alt", ref error); // if (error == -1) // { // Master.ShowMessage(String.Format("Önce \"{0}\" nolu hesabın oluşturulması gerekli.", parentCode), PageMaster.MsgType.Error); // return; // } // else if (error == -2) // { // Master.ShowMessage(String.Format("Alt olarak atanmış hesabın({0}) altına yeni hesap açılamaz.", parentCode), PageMaster.MsgType.Error); // return; // } // } //} try { da.InsertQuery(accountCode, parentCode, accountName, group, 0, riskLimit, currency, agrDate, agrTotal, agrNet, officer, adress, taxOffice, taxNo, phone, fax, email, web,user, DateTime.Now, ackMail, termRate, termDays, libraCode,cityCode,district, buyer,seller,checkLimit,uniqueCode,discountRate, ref error); } catch (System.Data.SqlClient.SqlException exception) { if (exception.Number == 547) { error = -99; } else if (exception.Number == 2627) { error = -100; } else { throw; } } if (error == -1) { Master.ShowMessage("Mizan kodu olarak kullanılan hesap kodlarının \"Alt\" olarak atanmış olması gerekir", PageMaster.MsgType.Error); } else if (error == -2) { Master.ShowMessage(String.Format("Önce ({0}) nolu üst hesabın açılması gerekiyor.", parentCode), PageMaster.MsgType.Error); } else if (error == -3) { Master.ShowMessage(String.Format("({0}) nolu üst hesabın \"Alt\" olarak atanması gerekir",parentCode), PageMaster.MsgType.Error); } else if(error == -4) { Master.ShowMessage(String.Format("Girilen özel kodun ({0}) tekrarı başka bir cari kartta bulunuyor.",uniqueCode), PageMaster.MsgType.Error); } else if (error == -99) { Master.ShowMessage(String.Format("Geçersiz mizan kodu. ({0})", libraCode), PageMaster.MsgType.Error); } else if (error == -100) { Master.ShowMessage(String.Format("({0}) nolu başka bir cari hesap bulunuyor.", accountCode), PageMaster.MsgType.Error); } else { Master.ShowMessage(String.Format("{0} ({1}) isimli yeni cari hesap kartı oluşturuldu.", accountName, accountCode) , PageMaster.MsgType.Info); } } if (error < 0) { account = accounts.NewCariKartRow(); account.adres = adress; account.bilglendirmeMaili = ackMail; account.borcAlacakDurumu = agrNet; account.cariAd = accountName; account.cariKod = accountCode; account.eMail = email; account.fax = fax; account.Gurup = group; account.MizanKodu = libraCode; if (agrTotal.HasValue) account.mutabakatMiktari = agrTotal.Value; if (agrDate.HasValue) account.mutabakatTarihi = agrDate.Value; account.paraBirimi = currency; account.risklimiti = riskLimit; account.tel = phone; account.VadeGunu = termDays; account.VadeOrani = termRate; account.vergiDairesi = taxOffice; account.vergiNo = taxNo; account.web = web; account.yetkili = officer; account.IlKodu = cityCode; account.Ilce = district; account.Alici = buyer; account.Satici = seller; account.CekLimiti = checkLimit; account.OzelKod = uniqueCode; account.kullanici = user; } else { account = da.GetDataByCariKod(accountCode)[0]; } } else if (Request.Params["DeleteAccount"] != null) { var deleted = da.DeleteQuery(accountCode); if (deleted > 0) { Master.ShowMessage(String.Format("{0} numaralı cari hesap silindi.", accountCode) , PageMaster.MsgType.Info); accountCode = ""; } else { Master.ShowMessage(String.Format("{0} nolu cari hesap bulunmuyor.", accountCode), PageMaster.MsgType.Error); } } if (account != null && !String.IsNullOrEmpty(account.MizanKodu)) { using (var daHesapPlani = new HesapPlaniTableAdapter()) { var accountPlan = daHesapPlani.GetDataByKod(account.MizanKodu); libraName = accountPlan.Count > 0 ? accountPlan[0].HesapAdi : ""; } } } } }
void gaapTable_OnInsertCommand(Dictionary<string, object> row,bool repeat) { using (var da = new HesapPlaniTableAdapter()) { int? error = null; try { var parentCode = row["Kod"].ToString().Substring(0, row["Kod"].ToString().LastIndexOf(".")); da.InsertMethod( (string)row["Kod"], parentCode, (string)row["HesapAdi"], (string)row["Tipi"], ref error); if (error == -1) { Master.ShowMessage(String.Format("Önce \"{0}\" nolu hesabın oluşturulması gerekli.", parentCode), PageMaster.MsgType.Error); } else if (error == -2) { Master.ShowMessage(String.Format("Alt olarak atanmış hesabın({0}) altına yeni hesap açılamaz.", parentCode), PageMaster.MsgType.Error); } } catch (SqlException exception) { if (exception.Number == 2627) { Master.ShowMessage(String.Format("Girdiğiniz hesap kodu({0}) hesap planında mevcut.", row["Kod"]), PageMaster.MsgType.Error); error = exception.Number; } else { throw exception; } } if (error.HasValue || repeat) //TODO use webcontrol inner logic for repeat { gaapTable.RetryCommand = new WebControls.RetryCommand { CommandName = "insert", BeforeID = Request.Params["editingRow_BeforeId"], Row = row, Repeat = repeat, Empty = !error.HasValue }; } } }
void gaapTable_OnUpdateCommand(Dictionary<string, object> row) { using (var da = new HesapPlaniTableAdapter()) { int? error = null; da.UpdateQuery( row["Kod"].ToString(), null, row["HesapAdi"].ToString(), row["Tipi"].ToString(), ref error); if (error == -1) { Master.ShowMessage("Alt hesabı bulunan hesaplar \"Alt\" olarak atanamaz.", PageMaster.MsgType.Error); } else if(error == -2) { Master.ShowMessage("Cari karta bağlanmış hesaplar \"Ara\" olarak atanamaz.", PageMaster.MsgType.Error); } if (error.HasValue) { gaapTable.RetryCommand = new WebControls.RetryCommand { CommandName = "update", BeforeID = row["Kod"].ToString(), Row = row }; } } }