Ejemplo n.º 1
0
        private void init()
        {
            try
            {
                refList = new List <ReferenceObj>();
                List <BuyerObj> buyerList = new BuyerDao().list();
                nameCbb.DisplayMemberPath = "name";
                nameCbb.ItemsSource       = buyerList;
                seller         = new SellerDao().select();
                vatTb.Text     = seller.vat.ToString("N");
                this.invoiceID = PREFIX + seller.dbn_no;

                List <CauseCodeListObj> list = new CauseCodeListDao().list("ใบเพิ่มหนี้");
                purposeCbb.DisplayMemberPath = "description";
                purposeCbb.SelectedValuePath = "code";
                purposeCbb.ItemsSource       = list;
                purposeCbb.SelectedIndex     = 0;
                otherPurposeTb.IsEnabled     = false;
                setProvinceList();

                is_main.IsChecked       = true;
                taxIdType.SelectedIndex = 0;
                taxIdTypeControl(0);
            }
            catch (Exception ex)
            {
                new AlertBox(ex.Message).ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void init()
        {
            try
            {
                refList = new List <ReferenceObj>();
                List <BuyerObj> buyerList = new BuyerDao().list();
                nameCbb.DisplayMemberPath = "name";
                nameCbb.ItemsSource       = buyerList;
                seller     = new SellerDao().select();
                vatTb.Text = seller.vat.ToString("N");
                //this.invoiceID = seller.running_prefix + seller.running_number;
                this.invoiceID = PREFIX + seller.inv_no;

                List <CauseCodeListObj> list = new CauseCodeListDao().list("ยกเลิกและออกใบกำกับภาษี ฉบับใหม่แทนฉบับเดิม");
                purposeCbb.DisplayMemberPath = "description";
                purposeCbb.SelectedValuePath = "code";
                purposeCbb.ItemsSource       = list;
                purposeCbb.SelectedIndex     = 0;
                setProvinceList();
            }
            catch (Exception ex)
            {
                new AlertBox(ex.Message).ShowDialog();
            }
        }
Ejemplo n.º 3
0
        internal SellerObj select()
        {
            string txtQuery = string.Format("SELECT * FROM {0} LIMIT 1", this.tableName);

            try
            {
                SellerObj data = new SellerObj();
                using (SQLiteConnection c = new SQLiteConnection(sqlite.ConnectionString))
                {
                    c.Open();
                    using (SQLiteCommand cmd = new SQLiteCommand(txtQuery, c))
                    {
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.Read())
                            {
                                data.id       = Convert.ToInt32(dr["id"]);
                                data.name     = dr["name"].ToString();
                                data.taxId    = dr["tax_id"].ToString();
                                data.phoneNo  = dr["phone_no"].ToString();
                                data.phoneExt = dr["phone_ext"].ToString();
                                data.zipCode  = dr["zipcode"].ToString();
                                data.address1 = dr["address1"].ToString();
                                //data.address2 = dr["address2"].ToString();
                                data.houseNo = dr["house_no"].ToString();
                                data.email   = dr["email"].ToString();
                                //data.website = dr["website"].ToString();
                                //data.faxNo = dr["fax_no"].ToString();
                                //data.faxExt = dr["fax_ext"].ToString();
                                data.isBranch = Convert.ToBoolean(dr["is_branch"]);
                                data.branchId = dr["branch_id"].ToString();
                                data.vat      = Convert.ToDouble(dr["vat"]);
                                //data.running_prefix = dr["running_prefix"].ToString();
                                //data.running_number = dr["running_number"].ToString();

                                data.provinceCode    = dr["province_code"].ToString();
                                data.provinceName    = dr["province_name"].ToString();
                                data.districtCode    = dr["district_code"].ToString();
                                data.districtName    = dr["district_name"].ToString();
                                data.subdistrcitCode = dr["subdistrict_code"].ToString();
                                data.subdistrictName = dr["subdistrict_name"].ToString();
                                data.houseNo         = dr["house_no"].ToString();
                                data.inv_no          = dr["inv_no"].ToString();
                                data.dbn_no          = dr["dbn_no"].ToString();
                                data.crn_no          = dr["crn_no"].ToString();
                            }
                        }
                    }
                }
                return(data);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private bool saveData()
        {
            try
            {
                validateData();
                SellerObj obj = new SellerObj();
                obj.id       = this.id;
                obj.name     = nameTb.Text;
                obj.houseNo  = houseNoTb.Text;
                obj.address1 = address1Tb.Text;
                obj.zipCode  = zipcodeTb.Text;
                obj.taxId    = taxIdTb.Text;
                if (is_branch.IsChecked.Value)
                {
                    obj.isBranch = true;
                    obj.branchId = branchNoTb.Text;
                }
                else
                {
                    obj.isBranch = false;
                    obj.branchId = "00000";
                }
                obj.email    = emailTb.Text;
                obj.vat      = Convert.ToDouble(vatTb.Text);
                obj.phoneNo  = phoneNoTb.Text;
                obj.phoneExt = phoneExtTb.Text;

                obj.inv_no          = invRunningNumberTb.Text;
                obj.dbn_no          = dbnRunningNumberTb.Text;
                obj.crn_no          = CrnRunningNumberTb.Text;
                obj.provinceCode    = ((AddressCodeListObj)provinceCbb.SelectedItem).code.Substring(0, 2);
                obj.provinceName    = ((AddressCodeListObj)provinceCbb.SelectedItem).changwat_th;
                obj.districtCode    = ((AddressCodeListObj)amphoeCbb.SelectedItem).code.Substring(0, 4);
                obj.districtName    = ((AddressCodeListObj)amphoeCbb.SelectedItem).amphoe_th;
                obj.subdistrcitCode = ((AddressCodeListObj)tambonCbb.SelectedItem).code.Substring(0, 6);
                obj.subdistrictName = ((AddressCodeListObj)tambonCbb.SelectedItem).tambon_th;

                new SellerDao().save(obj);
                new AlertBox("บันทึกข้อมูลผู้ขายเรียบร้อยแล้ว").ShowDialog();
                this.Close();
                return(true);
            }
            catch (Exception ex)
            {
                new AlertBox(ex.Message).ShowDialog();
                return(false);
            }
        }
Ejemplo n.º 5
0
        private int saveContact(SellerObj obj)
        {
            ContactObj contact = new ContactObj();

            contact.name     = obj.name;
            contact.taxId    = obj.taxId;
            contact.branchId = obj.branchId;
            contact.email    = obj.email;
            contact.zipCode  = obj.zipCode;
            contact.address1 = obj.address1;
            contact.country  = "TH";
            contact.phoneNo  = obj.phoneNo;
            contact.phoneExt = obj.phoneExt;

            contact.provinceCode    = obj.provinceCode;
            contact.provinceName    = obj.provinceName;
            contact.districtCode    = obj.districtCode;
            contact.districtName    = obj.districtName;
            contact.subdistrcitCode = obj.subdistrcitCode;
            contact.subdistrictName = obj.subdistrictName;
            contact.houseNo         = obj.houseNo;
            return(new ContactDao().save(contact));
        }
Ejemplo n.º 6
0
        internal void save(SellerObj obj)
        {
            string txtQuery = string.Empty;

            if (obj.id == 0)
            {
                txtQuery = string.Format("INSERT INTO {0} (name,tax_id,phone_no,phone_ext,zipcode,address1,email,vat,is_branch,branch_id"
                                         + ",province_name,province_code,district_name,district_code,subdistrict_name,subdistrict_code,house_no,inv_no,dbn_no,crn_no) VALUES ", this.tableName);
                string values = string.Format("(@name,@tax_id,@phone_no,@phone_ext,@zipcode,@address1,@email,@vat,@is_branch,@branch_id"
                                              + ",@province_name,@province_code,@district_name,@district_code,@subdistrict_name,@subdistrict_code,@house_no,@inv_no,@dbn_no,@crn_no)");
                txtQuery = txtQuery + values;
            }
            else
            {
                txtQuery = string.Format("UPDATE {0} SET ", this.tableName);
                string values = string.Format("name=@name,tax_id=@tax_id,phone_no=@phone_no,phone_ext=@phone_ext,zipcode=@zipcode,address1=@address1"
                                              + ",email=@email,vat=@vat,is_branch=@is_branch,branch_id=@branch_id,province_name=@province_name,province_code=@province_code"
                                              + ",district_name=@district_name,district_code=@district_code,subdistrict_name=@subdistrict_name,subdistrict_code=@subdistrict_code"
                                              + ",house_no=@house_no,inv_no=@inv_no,dbn_no=@dbn_no,crn_no=@crn_no ");
                string condition = string.Format("WHERE id=@id");
                txtQuery = txtQuery + values + condition;
            }
            using (SQLiteConnection c = new SQLiteConnection(sqlite.ConnectionString))
            {
                c.Open();
                using (SQLiteCommand cmd = new SQLiteCommand(txtQuery, c))
                {
                    cmd.Parameters.AddWithValue("@name", obj.name);
                    cmd.Parameters.AddWithValue("@tax_id", obj.taxId);
                    cmd.Parameters.AddWithValue("@phone_no", obj.phoneNo);
                    cmd.Parameters.AddWithValue("@phone_ext", obj.phoneExt);
                    cmd.Parameters.AddWithValue("@zipcode", obj.zipCode);
                    cmd.Parameters.AddWithValue("@address1", obj.address1);
                    cmd.Parameters.AddWithValue("@email", obj.email);
                    cmd.Parameters.AddWithValue("@vat", obj.vat);
                    cmd.Parameters.AddWithValue("@is_branch", (obj.isBranch) ? 1 : 0);
                    cmd.Parameters.AddWithValue("@branch_id", obj.branchId);

                    cmd.Parameters.AddWithValue("@province_name", obj.provinceName);
                    cmd.Parameters.AddWithValue("@province_code", obj.provinceCode);
                    cmd.Parameters.AddWithValue("@district_name", obj.districtName);
                    cmd.Parameters.AddWithValue("@district_code", obj.districtCode);
                    cmd.Parameters.AddWithValue("@subdistrict_name", obj.subdistrictName);
                    cmd.Parameters.AddWithValue("@subdistrict_code", obj.subdistrcitCode);
                    cmd.Parameters.AddWithValue("@house_no", obj.houseNo);
                    cmd.Parameters.AddWithValue("@inv_no", obj.inv_no);
                    cmd.Parameters.AddWithValue("@dbn_no", obj.dbn_no);
                    cmd.Parameters.AddWithValue("@crn_no", obj.crn_no);
                    if (obj.id != 0)
                    {
                        cmd.Parameters.AddWithValue("@id", obj.id);
                    }
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }