private void EditUser() { if (DGVUsers.SelectedRows.Count <= 0) { return; } long SyncId = Convert.ToInt64(DGVUsers.SelectedRows[0].Cells["id"].Value); user = new cls_user(); user.setcls_user_by_wid(SyncId, true); EnableUserModifierPanel(); tbx_Usercode.Text = user.getusercode().Trim(); tbx_Fullname.Text = user.getfullname().Trim(); tbx_Username.Text = user.username.Trim(); tbx_Password.Text = user.password.Trim(); cmbx_position.Text = user.position.Trim(); foreach (KeyValuePair <string, CheckBox> dicentry in AuthDictionary) { dicentry.Value.Checked = (user.AuthorizationList.Contains(dicentry.Key)) ? true : false; } }
public frmLogInMain() { InitializeComponent(); serverDateTime = ""; isconnected = false; cashier = null; //fncFilter.set_theme_color(this); //cls_globalfunc.formaddkbkpevent(this); }
private bool IsValidData() { string userName = tbUserName.Text; string password = MD5EncryptionFunction.Encrypt(tbPassword.Text); string selectSql = @"SELECT * FROM `user` WHERE `status`=1 AND username = @username AND password = @password"; SqlParameters sqlParameters = new SqlParameters(); sqlParameters.Add(new SqlParameter("username", userName)); sqlParameters.Add(new SqlParameter("password", password)); DataTable resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters)); if (resultDt.Rows.Count <= 0) { fncFilter.alert(MessagesVariable.InvalidUserNameOrPasswod); ClearData(); tbUserName.Select(); return(false); } string code = resultDt.Rows[0]["usercode"].ToString(); string fullName = resultDt.Rows[0]["fullname"].ToString(); string syncId = resultDt.Rows[0]["SyncId"].ToString(); selectSql = @"SELECT * FROM `userauth` WHERE `userid` = @userwid"; sqlParameters.Clear(); sqlParameters.Add(new SqlParameter("userwid", syncId)); resultDt = MySqlFunction.GetDataTable(new SqlDetail(selectSql, sqlParameters)); List <string> Authorizations = new List <string>(); foreach (DataRow dr in resultDt.Rows) { Authorizations.Add(dr["authorization"].ToString()); } User = new cls_user(); User.setcls_user(code, fullName, Authorizations, Convert.ToInt32(syncId)); return(true); }
// GET: api/Users public IEnumerable <cls_user> GetAspNetUsers() { List <cls_user> alluser = new List <cls_user>(); cls_user user_to_add = new cls_user(); var allAspnetUsers = db.AspNetUsers.Where(x => x.UserName != User.Identity.Name); foreach (var item in allAspnetUsers) { user_to_add = new cls_user(); user_to_add.Id = item.Id; user_to_add.UserName = item.UserName; user_to_add.State = item.State; user_to_add.Residence = item.Residence; user_to_add.Photograph = item.Photograph; user_to_add.Photo = item.Photo; user_to_add.PhoneNumberConfirmed = item.PhoneNumberConfirmed; user_to_add.PhoneNumber = item.PhoneNumber; user_to_add.IsInstructor = item.IsInstructor; user_to_add.IdCard = item.IdCard; user_to_add.GuaranteeDecument = item.GuaranteeDecument; user_to_add.Gender = item.Gender; user_to_add.EmailConfirmed = item.EmailConfirmed; user_to_add.Email = item.Email; user_to_add.Country = item.Country; user_to_add.Apout = item.Apout; user_to_add.AnotherAccount = item.AnotherAccount; user_to_add.IdCardBack = item.IdCardBack; user_to_add.facebookAccount = item.facebookAccount; user_to_add.twitterAccount = item.twitterAccount; user_to_add.jobTitle = item.jobTitle; alluser.Add(user_to_add); } return(alluser); }
public int save_transaction(cls_POSTransaction trans) { string datetime_d = trans.getdatetime().ToString("yyyy-MM-dd HH:mm:ss"); string branchid = cls_globalvariables.BranchCode; long salesheadwid = trans.getSyncId(); long customerid = trans.getcustomer().getwid(); string customername = trans.getcustomer().getfullname(); decimal adjust = trans.getadjust(); string seniorno = trans.getsenior().get_idnumber(); string seniorname = trans.getsenior().get_fullname(); long userid = trans.getclerk().getsyncid(); long memberid = trans.getmember().getSyncId(); long checkerid = trans.getchecker().getsyncid(); decimal totalamt = trans.get_productlist().get_totalamount(); bool iswholesale = trans.get_productlist().get_iswholesale(); bool isnonvat = trans.get_productlist().get_isnonvat(); decimal discount = trans.getdiscount(); decimal totalpaidamt = trans.getpayments().get_totalamount(); decimal t = trans.get_productlist().get_totalamount(); decimal t2 = trans.get_productlist().get_totalamount_no_head_discount(); decimal headDiscountPercentage = (t2 == 0) ? 0 : (t / t2); decimal cash = trans.getpayments().get_cash(); decimal mem_points = trans.getpayments().get_points(); decimal change = trans.get_changeamount(); List <cls_cardinfo> creditcards = trans.getpayments().get_creditcard(); List <cls_cardinfo> debitcards = trans.getpayments().get_debitcard(); List <cls_giftcheque> giftchequesnew = trans.getpayments().get_giftchequenew(); List <cls_CustomPaymentsInfo> custompaymentsinfo = trans.getpayments().get_custompayments(); string sSQLcd = ""; List <string> tempStringList = new List <string>(); // DO NOT DELETE // //MEMBER (Priority since it will be run on main branch) // if (trans.getmember().getwid() != 0) // { // List<string> memberTransactionListString = new List<string>(); // if (mem_points != 0) // { // tempStringList = get_next_wid_withlock_main_liststring("memberpointtrans"); // foreach (string str in tempStringList) // memberTransactionListString.Add(str); // string sSQLmemberpoint_d = @"UPDATE `memberpointtrans` SET // `memberid` = " + trans.getmember().getwid() + @", // `branchid` = " + branchid + @", // `type` = 3, // `referencewid` = " + salesheadwid.ToString() + @", // `amount` = " + mem_points + @", // `status` = 1, // `date` = NOW(), // `status` = 1, // `datecreated` = NOW(), // `lastmodifieddate` = NOW(), // `userid` = " + userid + @", // `lastmodifiedby` = " + userid + @" // WHERE `SyncId` = @syncid_d;"; // memberTransactionListString.Add(sSQLmemberpoint_d); // } // if (trans.getmember().getwid() != 0) // { // decimal point_earn = trans.get_memberpoint_earn(); // List<string> temp = get_next_wid_withlock_main_liststring("memberpointtrans"); // foreach (string str in temp) // memberTransactionListString.Add(str); // string sSQLmemberpoint = @"UPDATE `memberpointtrans` SET // `memberid` = " + trans.getmember().getwid() + @", // `branchid` = " + branchid + @", // `type` = 1, // `referencewid` = " + salesheadwid.ToString() + @", // `amount` = " + point_earn.ToString("N2") + @", // `status` = 1, // `date` = NOW(), // `datecreated` = NOW(), // `lastmodifieddate` = NOW(), // `userid` = " + userid + @", // `lastmodifiedby` = " + userid + @" // WHERE `SyncId` = @syncid_d;"; // memberTransactionListString.Add(sSQLmemberpoint); // } // //'select' is purposely lower cased for exec_trans method // memberTransactionListString.Add(@"select 'SUCCESS';"); // if (!mySQLFunc.check_connection_main() || exec_trans_main(memberTransactionListString, 3) != "SUCCESS") // return 1; // } string discquery = @""; List <string> transactionQueryList = new List <string>(); string sSQL = ""; sSQL = @"UPDATE `saleshead` SET `salesman` = " + trans.getsalesman().getsyncid().ToString() + @", `status` = 1, `customerid` = " + customerid + @", `customername` = '" + escapeString(customername) + @"', `date` = NOW(), `adjust` = " + adjust + @", `discount1` = " + discount + @", `seniorno` = '" + seniorno + @"', `seniorname` = '" + escapeString(seniorname) + @"', `ornumber` = '" + trans.getORnumber() + @"', `userid` = '" + userid + @"', `branchid` = '" + branchid + @"', `lastmodifiedby` = " + userid + @", `lastmodifieddate` = NOW(), `memberid` = " + memberid + @", `checkerid` = " + checkerid + @", `iswholesale` = " + iswholesale + @", `isnonvat` = " + isnonvat.ToString() + @" WHERE `SyncId` = " + salesheadwid; //Console.WriteLine(sSQL); //setdb(sSQL); transactionQueryList.Add(sSQL); foreach (cls_product prod in trans.get_productlist().get_productlist()) { string qty = prod.getQty().ToString("G29"); string price = (prod.getPrice()).ToString(); string vat = prod.getVat().ToString(); cls_user soldby = (cls_user)prod.getSoldBy(); long soldbywid = 0; try { soldbywid = soldby.getsyncid(); } catch { soldbywid = userid; } List <string> temp = GetListStringAndInsertNextSyncId("salesdetail"); foreach (string str in temp) { transactionQueryList.Add(str); } transactionQueryList.Add("SET @salesdetailwid := @SyncId"); int issenior = (trans.getsenior().get_idnumber().Length >= 1 && prod.getIsSenior() != 0) ? prod.getIsSenior() : 0; string sSQLdetail = @"UPDATE `salesdetail` SET `headid` = '" + salesheadwid + @"', `productid` = '" + prod.getSyncId().ToString() + @"', `quantity` = '" + qty + @"', `oprice` = '" + prod.getOrigPrice().ToString() + @"', `regularDC` = '" + prod.getDiscount().ToString() + @"', `price` = '" + price + @"', `pprice` = '" + prod.getPurchasePrice().ToString() + @"', `vat` = '" + vat + @"', `soldby` = '" + soldbywid + @"', `memo` = '" + prod.getMemo() + @"' WHERE `SyncId` = @salesdetailwid"; //Console.WriteLine(sSQLdetail); //setdb(sSQLdetail); transactionQueryList.Add(sSQLdetail); } tempStringList = GetListStringAndInsertNextSyncId("collectionhead"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } transactionQueryList.Add(@"SET @collectionheadwid := @syncid_d"); string sSQLch = @"UPDATE `collectionhead` SET `customerid` = " + customerid + @", `collectiondate` = NOW(), `userid` = " + userid + @", `status` = 1, `branchid` = " + branchid + @", `lastmodifieddate` = NOW(), `lastmodifiedby` = " + userid + @", `datecreated` = NOW(), `memo` = '" + trans.getpayments().get_memo() + @"', `show` = 1 WHERE `SyncId` = @collectionheadwid"; //Console.WriteLine(sSQLch); //setdb(sSQLch); transactionQueryList.Add(sSQLch); string sSQLcs = @"INSERT INTO `collectionsales` (`headid`, `saleswid`, `amount`) VALUES ( @collectionheadwid, " + salesheadwid + ", " + (totalpaidamt - trans.get_changeamount()) + ")"; //Console.WriteLine(sSQLcs); //setdb(sSQLcs); transactionQueryList.Add(sSQLcs); if (cash != 0) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 1, `amount` = " + cash + @" WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } if (change > 0) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 1, `amount` = -" + change + @" WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } foreach (cls_cardinfo creditcard in creditcards) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 5, `amount` = " + creditcard.getamount() + @" WHERE `SyncId` = @syncid_d"; //Console.WriteLine(sSQLcd); //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); transactionQueryList.Add("SET @collectiondetailwid = @syncid_d"); tempStringList = GetListStringAndInsertNextSyncId("poscardpayment"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `poscardpayment` SET `collectiondetailid` = @collectiondetailwid, `cardsettingwid` = '" + cls_globalfunc.getCreditDebiCardInfo(creditcard.getcardno()) + @"', `cardno` = '" + creditcard.getcardno() + @"', `fullname` = '" + escapeString(creditcard.getname()) + @"', `expdate` = '" + creditcard.getexpdate().ToString("yyyy-MM-dd") + @"', `type` = '0', `approvalcode` = '" + escapeString(creditcard.getapprovalcode()) + @"', `amount` = '" + creditcard.getamount() + @"' WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } foreach (cls_cardinfo debitcard in debitcards) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 6, `amount` = " + debitcard.getamount() + @" WHERE `SyncId` = @syncid_d"; //Console.WriteLine(sSQLcd); //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); transactionQueryList.Add("SET @collectiondetailwid = @syncid_d"); tempStringList = GetListStringAndInsertNextSyncId("poscardpayment"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `poscardpayment` SET `collectiondetailid` = @collectiondetailwid, `cardno` = '" + debitcard.getcardno() + @"', `fullname` = '" + escapeString(debitcard.getname()) + @"', `expdate` = '" + debitcard.getexpdate().ToString("yyyy-MM-dd") + @"', `type` = '1', `approvalcode` = '" + escapeString(debitcard.getapprovalcode()) + @"', `amount` = '" + debitcard.getamount() + @"' WHERE `SyncId` = @syncid_d"; //Console.WriteLine(sSQLcd); //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } foreach (cls_giftcheque giftchequenew in giftchequesnew) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 13, `amount` = " + giftchequenew.getamount() + @" WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); transactionQueryList.Add("SET @collectiondetailwid = @syncid_d"); tempStringList = GetListStringAndInsertNextSyncId("posgiftchequepayment"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `posgiftchequepayment` SET `collectiondetailid` = @collectiondetailwid, `giftchequeno` = '" + giftchequenew.get_referenceno() + @"', `expdate` = '" + giftchequenew.getexpdate().ToString("yyyy-MM-dd") + @"', `memo` = '" + escapeString(giftchequenew.get_memo()) + @"', `amount` = '" + giftchequenew.getamount() + @"' WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } foreach (cls_CustomPaymentsInfo custompayment in custompaymentsinfo) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = " + custompayment.get_paymentwid() + @", `amount` = " + custompayment.get_amount() + @" WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); string field1info = custompayment.get_field1info(); string field2info = custompayment.get_field2info(); string field3info = custompayment.get_field3info(); string field4info = custompayment.get_field4info(); string field5info = custompayment.get_field5info(); string field6info = custompayment.get_field6info(); if (field1info.Length > 0 || field2info.Length > 0 || field3info.Length > 0 || field4info.Length > 0 || field5info.Length > 0 || field6info.Length > 0) { sSQLcs = @"INSERT INTO `poscustompayments` (`detailid`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`) VALUES ( @syncid_d, '" + escapeString(field1info) + @"', '" + escapeString(field2info) + @"','" + escapeString(field3info) + @"', '" + escapeString(field4info) + @"','" + escapeString(field5info) + @"', '" + escapeString(field6info) + @"')"; //setdb(sSQLcs); transactionQueryList.Add(sSQLcs); } } if (mem_points != 0) { tempStringList = GetListStringAndInsertNextSyncId("collectiondetail"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } sSQLcd = @"UPDATE `collectiondetail` SET `headid` = @collectionheadwid, `method` = 8, `amount` = " + mem_points + @" WHERE `SyncId` = @syncid_d"; //setdb(sSQLcd); transactionQueryList.Add(sSQLcd); } tempStringList = update_synctable_liststring("saleshead", salesheadwid.ToString()); foreach (string str in tempStringList) { transactionQueryList.Add(str); } tempStringList = update_synctable_liststring("collectionhead", "@collectionheadwid"); foreach (string str in tempStringList) { transactionQueryList.Add(str); } transactionQueryList.Add("select 'SUCCESS'"); string returnVal = exec_trans(transactionQueryList, 5); if (returnVal != "SUCCESS") { return(-1); } return(0); }
private void btnAdd_Click(object sender, EventArgs e) { user = new cls_user(); EnableUserModifierPanel(); }
public AddUserForm(cls_user cashier_d) { InitializeComponent(); Cashier = cashier_d; }